Using Anchors
Asked by Elise LaTorre:

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.


Answers:
author: Adam Laskowski
body: It looks like your anchors are misbehaving due to a bug:

[CONF-26433](https://jira.atlassian.com/browse/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.

comments: author: Elise LaTorre
body: Thank you for your help.


author: Hope Wyss
body: 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.


author: Guy Edkins
body: Still cannot get anchors to work in Confluence. Pretty much makes the wiki a useless tool in my opinion. This is HTML 101 people. Fix it!


author: mattcobb
body: It's a bug: <https://jira.atlassian.com/browse/CONFCLOUD-62589>

comments: author: Eric Wilson
body: Please Comment and Vote for the issue if you are reading this - Thanks Matt for posting the link .


author: Adam Laskowski
body: 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](https://developer.atlassian.com/display/CONFDEV/Confluence+XML-RPC+and+SOAP+APIs#ConfluenceXML-RPCandSOAPAPIs-RELATEDTOPICS)

comments: author: Elise LaTorre
body: 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.


author: Adam Laskowski
body: 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):

![](https://confluence.atlassian.com/download/attachments/315327189/macro.png?api=v2)

Next, add the anchor name:

![](https://confluence.atlassian.com/download/attachments/315327189/anchorname.png?api=v2)

It should then look like this:

![](https://confluence.atlassian.com/download/attachments/315327189/anchoradded.png?api=v2)

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

![](https://confluence.atlassian.com/download/attachments/315327189/addlink.png?api=v2)

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.


author: Peter Davis
body: Not a bug still but wack a doodle setup... The anchor in the header issue is still an issue but the man decided not to fix it.

The link to the anchor has to include both the page name and the anchor name after the #. This ain't HTML.

*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*

*Real world example:*

*atlassian.net/wiki/spaces/\~817853876/pages/756809729/Lorem+ipsum#Loremipsum-test*

*Page name = Loremipsum*

*Anchor name = test*

comments: author: Hauke H?rhold
body: Sure it's a bug.  
Confluence is creating the URL's as you showed above, but that doesn't say that it's jumping to them.

In some cases it's working as it should, in most cases it just ignores the anchor-click.


author: Lindsey
body: I think it is still a bug. I have the anchor at a non-heading level on one page and when I try to link to it on another page using page name#anchor name for the link, the link goes to the right page but does not scroll down to where the anchor is. Help please? None of the above helped me. I do have a table on the page with an anchor and a list of children elements on the page that contains the link to the anchor.

comments: author: Valentin K.
body: I think I've found the solution, any way worked for me.

In the description of anchors documentation, is mention that you need to add to link "Page name" and #" anchor name"

A half-hour of tests and make my draw.io work with my table and anchors inside this table!

In link you need to put ("Page name"**#** " Page name"**-**"anchor name")

I hope this will solve your problem!

![Anchor.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/64547iEEB3B3151DBD0811/image-size/large?v=v2&px=999 "Anchor.jpg")![Anchor in table.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/64548i02CA5934DA19329F/image-size/large?v=v2&px=999 "Anchor in table.jpg")


author: Mike Brandsma
body: Is this still a bug??

comments: author: Hauke H?rhold
body: Yes it is!


author: Sanjeev_Kumar
body: I am facing the same issue and the anchor links jumps to the target page but not to the specific heading.

comments: author: mattcobb
body: It is a bug: <https://jira.atlassian.com/browse/CONFCLOUD-62589>


author: Anthony Julian
body: Page [https://confluence.atlassian.com/display/DOC/Working+with+Anchors](https://confluence.atlassian.com/display/DOC/Working+with+Anchors?_ga=2.173957927.566009366.1529942611-1046278801.1513876175) has been deleted.


author: Tayger
body: This problem seems to exist since and over years. I'm pretty new to Confluence but running into same problem:

1. Creating an anchor "myanchor" inside page "linkedpage" by given Macro
2. In page "otherpage" (same space) creating a link\* to the anchor of linkedpage: "linkedpage#myanchor" by given link button

\* In the search field only the "otherpage" will be found, not the anchor itself. I also got some images as proposal but only 2 of like 50 images I have uploaded/used in my space.

Clicking on the link will heading me only to the top of the page but not the the position of "myanchor".

Funny part: On top of "linkedpage" the anchor "myanchor" (same page) works and jumps to the anchor position. It just doesnt work coming from other page.


author: Joanna de la Cruz
body: 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](http://www.atlassian.com/software/confluence) 6.3.2. Does anyone have a real fix yet?

comments: author: Brian Curtis
body: 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.


author: Amy Hogan
body: I have the same problem- is there a ticket open on this?


author: Brian Curtis
body: So far, our best guess is that some browsers and versions treat anchor links as case-specific, and others do not. #top doesn't always work the same as #Top.


author: colfinn
body: 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.


author: Jackie Wheeler
body: 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.


author: Elise LaTorre
body: Hi Charles,

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

comments: author: Charles Sands
body: I'm not using a TOC, I'm using the anchor macro from the Insert other macros menu.


author: Elise LaTorre
body: 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).


author: Charles Sands
body: 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.


author: Elise LaTorre
body: So you're using the "advanced" section of the link macro and inserting the **pagename#anchorname**? What happens?


author: Charles Sands
body: 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.


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


author: Charles Sands
body: I will if I can't resolve it on my own. Thanks for you help.


author: Adam Laskowski
body: 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](using-anchors/116850). If you're still stuck, we're happy to keep helping here, or via the Support portal.


author: Charles Sands
body: 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.


author: Adam Laskowski
body: 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>


author: Charles Sands
body: 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\>


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

[CONF-26765](https://jira.atlassian.com/browse/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.


author: Charles Sands
body: 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.


author: Charles Sands
body: 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.


author: Jessabean
body: 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.


author: Adam Laskowski
body: 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.

comments: author: Elise LaTorre
body: 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.


author: Jessabean
body: 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?


Tags: cloud

confluence-administration

confluence-cloud