How to link to a heading?
Asked by Ray Lehtiniemi:

Looks like cloud editor doesn't support anchors? so i have to try putting a url fragment with the heading title.

sometimes the link works, sometimes it just jumps to the page but does not scroll to the heading referenced in the URL fragment.

how is this supposed to work?


Answers:
author: Shannon S
body: Hello Ray,

Thank you for bringing this to our attention. I believe you might be running into the following bug:

* [CONFCLOUD-62589](https://jira.atlassian.com/browse/CONFCLOUD-62589) *Following a link to an anchor within another page doesn't scroll at all after getting to the other page*

When it does work, can you let me know if you are visiting from another page, or do you paste the URL into your address bar? Is there any difference that you notice compared to when the anchors do not work?

Regards,

Shannon

comments: author: Ray Lehtiniemi
body: Hi Shannon

Testing this morning, it seems like it works if i create a link to another page, with a URL fragment, and simply click it to open in the same tab. if i hit the back button, i am returned to the place i came from.

For URL fragment links to the same page, if i click a url fragment to same page, it works, but back button does not scroll to original location

If i Ctrl-click the link to open in a background tab, it does not work.

If i right click and open in new tab or new window, it does not work.

If i copy the URL, open a blank tab, and paste URL into address bar, it does not work.

so in general, it kinda seems to work for the limited case of just clicking a link and replacing the content in the current tab, but all other browsing patterns are just busted.

(and please note that all of this URL fragment business is just a gross hack to work around the lack of simple anchor/href hyperlinking functionality....)

Latest Chrome on Ubuntu Linux 18.04

Thanks

Ray


author: Shannon S
body: Ray,

Thank you for letting us know how you were able to work around this. As far as I can see now, the original bug is resolved. Could you tell me if you are still experiencing this issue?

Regards,

Shannon


author: Ray Lehtiniemi
body: Still appears to be happening.

Note, I'd rather not have to manually deal with URL fragments anyway Are there any plans to implement hypertext anchor/link functionality? that's kind of the whole point of a wiki.... and they should definitely support tabbed browsing!


author: Shannon S
body: Hello Ray,

My apologies for the long delay. In speaking to the developer on that case, he let me know that this fix was resolved for the old editor. In the new editor, there is no anchor feature, and at this time, you can only link to headings and comments.

Per the [Confluence Cloud Editor Roadmap](https://confluence.atlassian.com/confcloud/confluence-cloud-editor-roadmap-967314556.html):
> The anchor macro is temporarily unavailable, but in the meantime, you can use these workarounds:
>
> **Add a table of contents macro to your page**
>
> This automatically generates anchor links for each page header. To find those links, right-click (or on mobile, long-press) any of the headers in the table of contents, and copy the link address.
>
> **Use page headers as anchors**
>
> Anchors are automatically generated for each page header. To link to one, use the *https://pageURL#headingtext.*The anchor text must be formatted as it is on the page, including punctuation marks, but without spaces.
>
> For example, to link to this section, we would add *#Anchors* to the page URL, like so: <https://confluence.atlassian.com/display/ConfCloud/Confluence+Cloud+Editor+Roadmap#Anchors>

Can you confirm with me if the problem you are experiencing is with the new editor? You will be able to tell if the **Publish** button is in the top right-hand corner of the page while editing.

We are working on the solution for the anchors on the new editor in the meantime, and so you can follow this roadmap page for any updates.

Let me know if you have any questions about that.

Regards,

Shannon


author: Ray Lehtiniemi
body: Hi Shannon

Yah I'm using the new editor with the Publish at the top right, and the problem is present for both the TOC hack and the manual URL fragment hack.

A URL with a fragment only jumps to the target if you click it directly from a Confluence page into the same tab. ctrl-click and shift-click for tabbed browsing, and pasting a URL into the address bar for direct access are busted. they justshow the page and ignore the fragment.

Thanks

Ray


author: Ray Lehtiniemi
body: Just tried on firefox, not working there either.


author: Shannon S
body: Ray,

Thank you for confirming. So to confirm, the fix was only for the classic editor, as the anchor feature has not yet been fully implemented in the new editor.

This is the reason you are now seeing this behavior.

There's a similar bug here for the new editor:

* [CONFCLOUD-66822](https://jira.atlassian.com/browse/CONFCLOUD-66822) *Anchor Link does not redirect the user to the Anchor location in a Page when address link is copy-pasted in the address bar*

And a feature request you might be interested in as well since I believe it's similar to your request from earlier:

* [CONFCLOUD-25533](https://jira.atlassian.com/browse/CONFCLOUD-25533) *Provide a nicer way to link to page anchors*

Since the anchor feature is not yet released in the new editor, I would still encourage you to keep an eye on our Roadmap so you will know when the feature is available.

Regards,

Shannon


Tags: cloud

confluence-cloud