You can link to a specific location within a page, by marking that location with an Anchor macro and then linking to the anchor name. Anchor links can be especially useful when navigating between sections of a long document, or when you want to link to a segment of a page instead of the top of the page.

Anchors are invisible to the reader when the page is displayed.

There are two steps to using an anchor:

  1. Create the anchor on the page.
  2. Create the link to the anchor.

Creating an anchor

Use the Anchor macro to mark the location you want to link to.

  1. Add the Anchor macro to a page.
    1. In the Confluence editor, choose Insert > Other Macros.
    2. Find and select the required macro.

    Speeding up macro entry with autocomplete:

    Type { and the beginning of the macro name, to see a list of suggested macros. Details are in Using Autocomplete.

    To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.



  2. Specify the name of your anchor. For example, 'bottom' or 'important information'. See the 'Anchor Name' parameter described below.

Macro options (parameters)

Parameters are options that you can set to control the content or format of the macro output.

Parameter

Default

Description

Anchor Name

None

This is the anchor name that you will use when creating the link.

  • The anchor name can include spaces. Confluence will remove the spaces automatically when building a URL that points to this anchor.
  • The anchor name is case sensitive. You must use the same pattern of upper and lower case letters when creating the link as you use when creating the Anchor macro.

Creating a link to an anchor

You can link to an anchor from:
  • A link on the same page as the anchor
  • Another page in the same space
  • A page in another space of the same Confluence site.
  • Another web page or another Confluence site, using a specifically formatted URL.

To link to an anchor from within the same Confluence site:

  1. Edit the page where you want to place the link.
  2. Choose Link in the editor toolbar, or press Ctrl+K.
  3. Choose Advanced and enter the anchor name into the Link box, noting the following:

    • The anchor name is case sensitive. You must use the same pattern of upper and lower case letters as you used when creating the Anchor macro.
    • Use the following syntax:

      Anchor location

      Link syntax for anchor

      Examples

      Same page

      #anchorname

      #bottom

      #important information

      Different page

      pagename#anchorname

      My page#bottom

      My page#important information

      Page in another space

      spacekey:pagename#anchorname

      DOCS:My page#bottom

      DOCS:My page#important information

  4. Enter the Link Text (alias) that will be displayed on the page, if required. If you leave the 'Link Text' box empty, the link will display the destination page name or URL.
  5. Choose Insert.

To link to an anchor from another web page or another Confluence site:

Use a full URL in the following format:

Link syntax

Examples

http://myconfluence.com/display/spacekey/pagename#pagename-anchorname

http://myconfluence.com/display/DOCS/My+page#Mypage-bottom

http://myconfluence.com/display/DOCS/My+page#Mypage-importantinformation

Notes about the full URL:

  • The page name is repeated in the URL, after the # sign. The second occurrence of the page name is concatenated into a single word, with all spaces removed.
  • There is a single dash (hyphen) between the concatenated page name and the anchor name.
  • The anchor name in the full URL is concatenated into a single word, with all spaces removed.
  • The anchor name is case sensitive. You must use the same pattern of upper and lower case letters as you used when creating the Anchor macro.

Code examples

See:

Notes

  • Table of contents on page: Consider using the Table of Contents Macro to generate a list of links pointing to the headings on the page. The list of links will appear on the page, and will be automatically updated each time someone changes the wording of a heading.
  • Linking to headings: You can link directly to the headings of a page. See Linking to Pages. However, if someone changes the wording of a heading, those direct links will be broken. Use the Anchor macro to ensure a lasting link within the body of a page.
  • Site welcome message: If you are adding an anchor to a page that you are using in the site welcome message, you can only link to that anchor from another page. Internal links within that page will not work.
  • Templates: When you are previewing a template, a link to an anchor is displayed as a 'broken' link. However, when you create a page using the template the resulting page will have the correct link.