I am unable to get Anchors to work on my pages. I have read and followed the directions here: https://confluence.atlassian.com/display/DOC/Working+with+Anchors

I am trying to anchor a heading on at page, however, the link only takes me back to the page, not to the anchor section.

10 answers

1 accepted

It looks like your anchors are misbehaving due to a bug:

CONF-26433

The Table of Contents macro is creating an anchor target that's intercepting your desired anchor because of a formatting bug. If you add an anchor to an existing heading, it causes the TOC to create a second anchor inside of its list, which causes the page focus in your link to go to the TOC link instead of the actual anchor.

To get around this, just delete the current UserGroup anchor, and remake it at the end of the previous section as a new line above the heading. It should still link to the heading as expected.

If you copy your existing anchor macro and move it one line up, make sure you click-select the macro and change the format drop-down from Heading X to Paragraph, otherwise it will show up in your TOC macro as a blank line and continue to break anchor linking.

Thank you for your help.

I have Page A with a TOC. I want to link to a specific heading within this page.

I created an anchor at the end of the section before the heading I want to link to.

I've added a link to Page B = Page Name#anchorname. The link opens to the top of Page A but will not open to the specified anchor.

I have followed all of the suggestions above and still can't get this to work.

When you follow the link that should take you to the anchor, what does the URL look like? It should look similar to:

http://baserURL/display/spacekey/Page+Name#PageName-AnchorName

If you're not using the Anchor macro and are manually linking to the heading, replace AnchorName with HeadingName in the above example for the same effect. You can also inspect the heading element with Chrome's dev tools feature or Firebug and look at the heading's id tag for the PageName-HeadingName text. You can add it to the page's normal URL after adding a # at the end and it should link to the anchor.

Side note: If there isn't enough content below your anchor to fill a full page in your browser window, the anchor will place your page view at the end of the page instead of placing the anchor at the top of the window. Here's an example using the Related Topics anchor from our Confluence API docs (mileage may vary based on window size):

Confluence XML-RPC and SOAP APIs - Related Topics

I am following the instructions from https://confluence.atlassian.com/display/DOC/Working+with+Anchors:

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:

      <th>

      Anchor location

      </th><th>

      Link syntax for anchor

      </th><th colspan="1">
      Examples
      </th>

      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.

I am following the syntax for an achor within the same space but on a different page. The result is that the link takes me to the top of the page, but not to the anchor. This is true regardless how much text is on my page below the anchor point.

I can link to the URL, but my understanding is that this link will break if my page is moved. This is why I want to use the Anchor method described above.

Here's the process I just used to get an anchor to work in a dev 4.3.2 instance. First, add the anchor macro on the line desired in the target page (my target page is called Test Anchor):

Next, add the anchor name:

It should then look like this:

Then, to insert a link on another page (I added it to a child page of Test Anchor), use the format of Page Name#Anchor Name and it should anchor properly to the target pages anchor location.:

If you're following this same process and it's still not working, try a second browser to make sure it's not a browser specific issue. I'm testing in Chrome and Firefox, but I'm happy to check others you may be using.

There are two places in the reponse with colons (":") but nothing after the colons. Is something supposed to be there?

Does this functionality work like the bookmark functionality does in Word? Specifically, where you create a bookmark next to a heading. You give the bookmark a specific name and then link to the bookmark and not the heading. This way, the heading name can change without breaking the link.

Bringing it to Confluence, is the "Anchor Name" something you create and then link to? Or are you just copying the URL by right-clicking on the heading link in the TOC of the page you want to link to?

If you are just copying and pasting an URL, what is the point of the Anchor macro? What does it do that a hyperlink doesn't? I thought the purpose of a macro (as a opposed to URL method) would be to make the links persist. If the Anchor macro doesn't do this, what does it do?

Sorry, I hosted the images on our docsite in my personal space, but didn't enable anonymous access to the images. >.<

Yes, it works similar to bookmarks in Word. You need to link to the anchor name in the macro as opposed to the id of the heading itself. Now that the pics are working, that will hopefully help clear that question up.

The benefits to using the macro is that if you rename the page, which would change the URL, Confluence will adjust your link to the target so that it matches. For instance, if I change my Test Anchor page to Anchor Test, the link on my other page that goes to the anchor will still work, adjusting automatically. If you use a static link, then you would need to edit your page and change TestAnchor#LoremIpsum to AnchorTest#LoremIpsum.

Sorry for the confusion with the images. They work now.

Hi Adam,

I am using Chrome and when I follow the steps you outline, I link to the page, but not to the anchor on the page. And yes, there is lots of text below the anchor.

Also, I thought that headings functioned like anchors, but I cannot link to those either.

This is all in the on demand product, if that helps.

ETA: After I add the link and save the page, when I edit the link, the anchor text is missing. For instance, I add pagename#anchorname but when I re-open the link, all I see is pagename.

I am using Firefox in the On-Demand version and the above solution is not working. It will link to the page but not the anchor.

Has this been solved? I'm having the same problem. I've created an anchor at a point in a page, #anchorname, and in a seperate page I'm trying to link to that anchor, page name#anchorname, so when that link is clicked on the other page opens up and the anchor scrolls to view, or perhaps it just opens up at the anchor. What is happening is the page with the anchor opens but it never scrolls down.

Hi Charles,

Are you using the TOC macro on your page? That affects how the anchors are used.

I'm not using a TOC, I'm using the anchor macro from the Insert other macros menu.

Are you anchoring to the same page? A different page? To a heading?

Our problem was caused by the TOC macro. Ultimately, I decided to anchor to Headings or Pages rather than to anchor tags, as the latter required too much management (we'd need to keep a list of all anchors in use, for instance).

I'm trying to anchor to a different page. I can anchor to the page but I'd prefer to anchor to the relavent section.

So you're using the "advanced" section of the link macro and inserting the pagename#anchorname? What happens?

The anchor is created, but when I link to it from a different page that link opens up the page but doesn't go to the anchor.

I think someone needs to be able to look at your pages. Have you opened a support ticket with Atlassian?

I will if I can't resolve it on my own. Thanks for you help.

The bug that is referenced in accepted answer covers the specific scenario of including an {anchor} macro on the same line as a heading, which adds the anchod id to the Table of Contents {toc} macro on the page, intercepting the anchor link. If you're having issues with linking to the anchor that is on a page without the {toc} macro, double check your steps against this guideline. If you're still stuck, we're happy to keep helping here, or via the Support portal.

I thought I was following that guide. The anchor is not on the same line as a heading. I wanted to set the anchor in a row in a table and that isn't working, so I tried just putting an anchor to a word on a page and that didn't work either. In every case, I get to the page containing the anchor but not the anchor itself.

What is the anchor id (you can inspect element on the rendered page with Chrome or Firebug), and what is the URL in your browser after you click the anchor link? For a page named 'Anchor Target' with an achor called 'test,' for example, it should look like:

http://baseURL/wiki/display/test/Anchor+Target#AnchorTarget-test

ok, on a page titled 'Logins & Account Info' I created an anchor at a spot near the bottom called 'Test'

On a seperate page I created a link to that anchor. Here is the information for the anchor.

<img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e2FuY2hvcjpUZXN0fQ&amp;locale=en_GB&amp;version=2" data-macro-name="anchor" data-macro-default-parameter="Test" data-mce-src="http://marilyn:8101/plugins/servlet/confluence/placeholder/macro?definition=e2FuY2hvcjpUZXN0fQ&amp;locale=en_GB&amp;version=2">

and here is the information for the link on the other page:

<a class="confluence-link" href="/pages/viewpage.action?pageId=3735558#Logins&amp;amp;AccountInfo-Test" data-anchor="Test" data-linked-resource-id="3735558" data-linked-resource-type="page" data-linked-resource-default-alias="Logins &amp;amp; Account Info#Test" data-base-url="http://marilyn:8101" data-mce-href="http://marilyn:8101/pages/viewpage.action?pageId=3735558#Logins&amp;amp;AccountInfo-Test">Test</a>

You're running into a separate bug because of the special character in your page title:

CONF-26765

Try adding an achor on a test page with a single word, all text title, then link to it from elsewhere using the same method you've been trying and it should work.

That did the trick. I just removed the & and the anchor worked as expected. I can't reach that link though it keeps telling me I need to verify my email even though I've done that.

I am having a simillar issue with links in Firefox. If I link to an anchor (or just to a heading name) on another page, the page opens and it jumps to the right spot, but then it immediately jumps up about a page to a random spot in the content. If I enter the same URL in the URL bar when I'm viewing the target page, it works fine...the extra jump only happens when I use the URL while a different page is displayed. This doesn't happen in Safari.

Hi. I am coming in late to this discussion and you all may have already received your answers, but I thought I would jot down my experience so the Atlassian folks are aware of what I just discovered (if they aren't already).

I was having the same problem as everyone else in this string. However, one one page, all internal links worked. On a different page, NONE of them worked--yet, they were all created in exactly the same way (the way Confluence instructs on their Working with Anchors page).

I endlessly compared the two pages to see what was different. The only thing that remained was the title of the page: one title had no punctuation. The other title had an apostrophe 's. When I removed the apostrophe, all internal links worked.

Clearly, this is buggy and not intuitive. Hopefully Confluence will fix this in later updates.

Hope this helps.

I am also unable to get Anchors to work on my pages. I followed the suggestion "just delete the current UserGroup anchor, and remake it at the end of the previous section as a new line above the heading. It should still link to the heading as expected." That did not work. I have no special characters in my headings, I've followed their instructions, still the anchor jumps to the top of the page. Using Atlassian Confluence 6.3.2. Does anyone have a real fix yet?

No, but I'm having the same problem. Anchor tags work for some of my colleagues, but not me. We're using the same browser versions, too.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

280 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you