Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using Anchors

Elise LaTorre December 13, 2012

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.

18 answers

1 accepted

2 votes
Answer accepted
Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 27, 2012

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.

Elise LaTorre December 27, 2012

Thank you for your help.

Hope Wyss March 27, 2014

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.

1 vote
Guy Edkins December 20, 2019

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!

1 vote
mattcobb September 11, 2018
Eric Wilson January 11, 2019

Please Comment and Vote for the issue if you are reading this - Thanks Matt for posting the link . 

1 vote
Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2012

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

Elise LaTorre December 17, 2012

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.

Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2012

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.

Like M K likes this
0 votes
Peter Davis August 30, 2019

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

Hauke Hörhold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2019

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.

0 votes
Lindsey August 12, 2019

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. 

Valentin K. August 28, 2019

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.jpgAnchor in table.jpg

0 votes
Mike Brandsma July 23, 2019

Is this still a bug??

Hauke Hörhold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2019

Yes it is!

0 votes
Sanjeev_Kumar September 7, 2018

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

mattcobb September 12, 2018
0 votes
Anthony Julian June 26, 2018
0 votes
Tayger June 10, 2018

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.

0 votes
Joanna de la Cruz February 19, 2018

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?

Brian Curtis March 30, 2018

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.

Amy Hogan May 31, 2018

I have the same problem- is there a ticket open on this?

Brian Curtis June 11, 2018

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.

0 votes
colfinn March 5, 2014

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.

0 votes
Jackie Wheeler May 21, 2013

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.

0 votes
Elise LaTorre February 5, 2013

Hi Charles,

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

Charles Sands February 5, 2013

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

Elise LaTorre February 5, 2013

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

Charles Sands February 5, 2013

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.

Elise LaTorre February 5, 2013

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

Charles Sands February 5, 2013

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.

Elise LaTorre February 5, 2013

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

Charles Sands February 5, 2013

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

Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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.

Charles Sands February 5, 2013

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.

Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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

Charles Sands February 5, 2013

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>

Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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.

Charles Sands February 5, 2013

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.

0 votes
Charles Sands February 5, 2013

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.

0 votes
Jessabean December 18, 2012

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.

0 votes
Adam Laskowski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2012

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.

Elise LaTorre December 17, 2012

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.

0 votes
Jessabean December 17, 2012

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events