# anchor macro in Confluence storage format

URL: https://goingstellar.ro/reference/confluence-storage-format/anchor-macro/

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

```xml
<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

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

## As ADF (Confluence Cloud)

The ADF that Confluence Cloud builds for:

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

```json
{
 "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:

```xml
<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):

```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:

```xml
<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 29 Nov 2026.

Storage format sent:

```xml
<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):

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

Storage format after the round trip through ADF:

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

Sent to Confluence Cloud on 29 Nov 2026.

Storage format sent:

```xml
<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):

```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:

```xml
<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 29 Nov 2026.

## 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.

## Related

- [toc and toc-zone macros](https://goingstellar.ro/reference/confluence-storage-format/table-of-contents/)
- [expand macro](https://goingstellar.ro/reference/confluence-storage-format/expand/)
- [excerpt, excerpt-include and include macros](https://goingstellar.ro/reference/confluence-storage-format/excerpt-include/)
- [status macro](https://goingstellar.ro/reference/confluence-storage-format/status/)

## Sources

- [Insert the anchor link macro (Atlassian Support)](https://support.atlassian.com/confluence-cloud/docs/insert-the-anchor-macro/)
- [Confluence storage format (Atlassian Documentation)](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html)
- [Atlassian Document Format: document structure (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/)

