I have a Confluence (Server, 6.7.0) page with the title "5 Information security policies". (Yes, with a "hardcoded" heading number... possibly too much information: this heading is a "control" from ISO/IEC 27001:2013 Annex A.)
The page contains the heading "5.1.2 Review of the policies for information security". (If Confluence supported search'n'replace across pages out of the box, I would consider chunking the page so that this "5.1.2" heading was its own page, and the problem I'm having would evaporate. But that's another discussion.)
I've inserted an Anchor macro, with the anchor name "5.1.2", at the start of that "5.1.2 ..." heading.
Here's what I did to create a link to that anchor (that heading) from another page in the same space:
When I view the saved page and inspect the resulting link, here's the URL (I've replaced some strings with "..."):
http:// ... /pages/createpage.action?spaceKey= ... &title=5+Information+security+policies&linkCreation=true&fromPageId=...
Clicking the link creates a new page, which is not what I want.
How do I create a link to the anchor? What am I doing wrong?
Is there is an issue with the periods in the anchor?
What just came to my mind right after my reply - is the page you create the link in the same space? Maybe you have to put the spacekey also in
XXX:5 Information security policies#5.1.2 (spacekey:page name#anchor name)
Thanks for the suggestions.
I'm embarrassed to admit that it was user error: my problem.
Yes, I selected "5 Information security policies#5.1.2" from the autocomplete entry that my browser (Chrome) displayed under the Link input text box, but a page with that title no longer existed. I'd forgotten that I'd appended a string in parentheses to the end of that page title: so the actual current page title was "5 Information security policies (...)#5.1.2" (I've used "..." instead of the actual string, which I don't want to show here).
I can't blame Confluence for that autocomplete entry; that's browser behavior, not Confluence.
You were right:
maybe '5 Information security policies' is a page that doesn't exist
Thanks again!
Apologies to all for my misleading "report".
P.S. I was initially nervous when the working URL showed the page title in the hash:
http:// ... /pages/viewpage.action?pageId=50332014#id-5Informationsecuritypolicies(...)-5.1.2
but I needn't have worried. When I edited the destination page, and changed its title, and then refreshed the page containing the link (in another browser tab), Confluence had updated the hash to reflect the edited page title. Phew.
Good to hear, - no worries that's what the community is all about :) helping and sharing experiences we made.
As you can imagine from what I've written - I've made similar experiences like you when setting anchors ;)
The full answer is in the anchor documentation. There are different syntaxes according to whether the anchor is on the same page, same space or different space.