Going Stellar

Home/Confluence storage format reference

Confluence storage format

anchor macro in Confluence storage format

The anchor macro places an invisible target on a page. Its one value is an unnamed parameter, written with an empty ac:name. A link reaches it with the ac:anchor attribute on ac:link. The macro converts cleanly, but an anchor on a link to another page is dropped.

Storage format

<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">section-two</ac:parameter></ac:structured-macro>
<ac:link ac:anchor="anchor"><ac:plain-text-link-body><![CDATA[Anchor Link]]></ac:plain-text-link-body></ac:link>

In the editor

HowNote
Select the insert button or type / and pick the anchor link macro, then link to the anchorPer the Atlassian documentation. Anchors are invisible when the page is viewed.

As ADF (Confluence Cloud)

The ADF that Confluence Cloud builds for:

<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">section-two</ac:parameter></ac:structured-macro>
{
 "type": "doc",
 "content": [
  {
   "type": "paragraph",
   "content": [
    {
     "type": "inlineExtension",
     "attrs": {
      "extensionType": "com.atlassian.confluence.macro.core",
      "extensionKey": "anchor",
      "parameters": {
       "macroParams": {
        "": {
         "value": "section-two"
        },
        "legacyAnchorId": {
         "value": "Examplepage-section-two"
        },
        "_parentId": {
         "value": "<page id>"
        }
       },
       "macroMetadata": {
        "macroId": {
         "value": "<id>"
        },
        "schemaVersion": {
         "value": "1"
        },
        "title": "Anchor"
       }
      }
     }
    }
   ]
  }
 ],
 "version": 1
}

Examples

Storage format sent

<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">section-two</ac:parameter></ac:structured-macro>

Create a target that another link can jump to. The stored page renders a hidden span with the anchor id.

Rendered view (HTML)

<span class="confluence-anchor-link conf-macro output-inline" data-hasbody="false" data-macro-id="<id>" data-macro-name="anchor" id="Examplepage-section-two"><span class="confluence-anchor-link" id="section-two"> </span></span>

Storage format after the round trip through ADF

<p><ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="">section-two</ac:parameter></ac:structured-macro></p>

Sent to Confluence Cloud on .

Storage format sent

<p><ac:link ac:anchor="anchor"><ac:plain-text-link-body><![CDATA[Anchor Link]]></ac:plain-text-link-body></ac:link></p>

Link to an anchor on the same page. The link is stored as a plain fragment link.

Rendered view (HTML)

<p><a href="#anchor">Anchor Link</a></p>

Storage format after the round trip through ADF

<p><ac:link ac:anchor="anchor"><ac:link-body>Anchor Link</ac:link-body></ac:link></p>

Sent to Confluence Cloud on .

Storage format sent

<p><ac:link ac:anchor="anchor"><ri:page ri:content-title="pagetitle"/><ac:plain-text-link-body><![CDATA[Anchor Link]]></ac:plain-text-link-body></ac:link></p>

Link to an anchor on another page by combining ac:anchor with ri:page. The page named in the link does not exist, so the link points to a create-page action.

Rendered view (HTML)

<p><a class="createlink" href="/wiki/pages/createpage.action?spaceKey=SD&amp;title=pagetitle&amp;linkCreation=true&amp;fromPageId=<page id>">Anchor Link</a></p>

Storage format after the round trip through ADF

<p><ac:link><ri:page ri:content-title="pagetitle" /><ac:link-body>Anchor Link</ac:link-body></ac:link></p>

Sent to Confluence Cloud on .

What changes in conversion

  • The macro is an ADF inlineExtension with key anchor. The value stays in the unnamed parameter, and ADF adds legacyAnchorId and _parentId entries.
  • After a round trip the macro is wrapped in a paragraph, because the extension is inline.
  • A same-page ac:link with ac:anchor becomes an ADF link with href #anchor and returns as an ac:link with ac:anchor and an ac:link-body.
  • A link that combines ac:anchor with ri:page loses its anchor on conversion. It returns pointing at the page with no fragment.

Pitfalls

  • The value sits in a parameter with an empty ac:name, which is how Confluence stores it after a save.
  • On the stored page the outer span carries an id prefixed with the page title, and an inner span carries the raw value.
  • Do not rely on cross-page anchor links in content that is saved from the Cloud editor. The fragment is the part that is lost.

Questions and answers

Is the anchor visible to readers?

No. The documentation says anchor links are invisible in view mode, and the stored view is two empty spans.

How is the anchor named in storage?

As the default parameter, with an empty ac:name.

Sources

  1. Insert the anchor link macro (Atlassian Support)
  2. Confluence storage format (Atlassian Documentation)
  3. Atlassian Document Format: document structure (Atlassian Developer)

Markdown version · All storage format pages