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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to link to an anchor on the page?

I have created an anchor on a page as follows

{anchor:here}

But I am unable to link to the above anchor. I am using Confluence 3.4.8. When I write the following markup in the rich text editor it displays the text as-is rather than showing it as a link to anchor.

[#here]

Am I missing something?

5 answers

I tried to repeat steps from Atlassian Achors tutorial, but confluence could not find my anchors (strange). This video helped me to make links to anchors work.

Briefly:

  • create an anchor with name "anchorname"
  • show "Insert link" popup -> Advanced tag -> in Link field enter "#anchorname" (without quotes). Save link, save draft.

You cannot simply past the markup in the Rich Text editor. You need to select the "Insert Macro" tool bar button (looks like a little scroll), choose the Anchor macro and then enter your anchor label as the target, with # preceeding. Then I believe the best choice is to insert your hyperlink using the Link macro.

My anchor has been created properly because when I save page and see the view it doesn't shows the anchor tag.

But the problem is I am not able to link to the anchor I have created. When I write [#here], it displays the text as is with "#" symbol.

Go ahead and paste the Wiki markup for your page here. We can probably explain it better that way.

0 votes
Joe Clark Atlassian Team Sep 15, 2011

Firstly, as Kevin says, you can't type anchor links like that directly into the Rich Text editor using wiki markup syntax - you should either swap to the wiki markup editor, or use the "link browser" dialog in the Rich Text editor to type in the link.

Secondly, I'm fairly certain you need to include the page title in the link, in addition to the name of the anchor, so try:

[PageTitle#anchorName]

To link to an anchor I followed following steps: -

1. In the rich text editor edit mode, pressed Ctrl+K to open link browser.

2. Typed the page name. As I started typing the page name confluence automatically lists the page names which inlucde that keywork which I am typing.

3. After entering page name I added anchor name like this - Home#Overview

4. Saved the page.

When I click on the link, it navigates me to the top of the Home page and not the Overview segment of the page. I check the wiki markup of the page for the link and it is as follows:

[Overview|MySpace:Home]

Above markup is in the form: -

[<Link text>|<space name>:<Page title>]

It doesn't include the anchor name, even when I specified the anchor name at the time of specifying the link in the link browser. When I modify the above markup in the "wiki markup" view as below it works fine.

[Overview|MySpace:Home#Overview]

So, it seems to me that there is some bug in Confluence. When we give anchor name from link browser it doesn't include it in the markup, but when I explicitly mention the anchor name in the "wiki markup" view, it works absolutely fine.

I think this is beyond the scope of the rich text editor in Confluence versions < 4.0. It is most reliably done in Wiki markup.

Is it the problem with ver. < 4.0? How about ver. 4.0 or greater?

Everything related to such problems changes in 4.0 and such problems are excluded by design. It is a whole new editor.

I just wasted hours trying to do this. I added the anchor macro to the bottom of a page and gave it the name Bookmark.
I navigated to another page in a different space and inserted a link using the advanced option. I entered IHopeThisWorks as the link text followed by spacekey:pagename#Bookmark (obiviously using the actual space key and page name and it did not work.
Is there an issue when using special characters in a page name?

I don't think there is an issue with special characters in this regard only. Just tried the following: Inserting an HTML link via code editor as <a name="anchorname">xxx</a> and it won't work , too. The tags are deleted while being parsed, creating a blank output of "xxxx"  I checked the code, there are no tags anymore an dlinking doesn't work. This means it wouldn't be possible to set alink to an achor from outside the system at all. *sad*

Never use capitals or special chracters in identifier's or variable's names.

I just discovered the following workaround:

 

Link to a heading on a page

Choose Link > Advanced then enter the heading in one of the formats below. Heading text is case sensitive and must be entered without spaces.

  • For a heading on this page: #MyHeading.

https://confluence.atlassian.com/confcloud/insert-links-and-anchors-724764900.html

But in order to answer your question: Never use special characters or capitals when naming variables or identifiers

Sorry for crossposting my own comments. Found a solution to link from outside. It's a little bit crude: Confluence uses the following syntax when it comes to anchor linking: http://domain.com/display/SPACESHORTCUT/pagename#pagename-anchorname

I've also spent hours (if not days) trying to get linking to Confluence page anchors from external pages (including in some cases, ironically, Jira tickets) and the above info finally solved most cases for me.

However, I've figured out some nuances that are worth adding here to save others' time:

Using the basic structure above:

http://domain.com/display/SPACESHORTCUT/pagename#pagename-anchorname

1) Page titles with punctuation (specifically brackets "(" & ")" but may include others:

The punctuation marks are
- removed from the pagename in the URL path (left of the #)
- retained in the pagename in the URL fragment (right of the #)

example 

For a page title "This & That" with anchor "001", the link would be

http://domain.com/display/SPACESHORTCUT/This+That#This&That-001

2) Page titles that start with a number:

The pagename in the URL fragment seems to get prefixed with "id-"

e.g For a page title "1 Guide" with anchor "001", the link would be

http://domain.com/display/SPACESHORTCUT/1+Guide#id-1Guide-001

Like # people like this

@Jon Wilkinsthanks Jon!  your examples helped me out a TON!

I had a need to add a link to a paragraph in the same page; to do so I have added a Table of Content that has generated all the links to all headings in the page. Then where I needed to add the link I have simply added the link as per ToC

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,560 views 6 7
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you