External web page to get link to anchor placed on Confluence user home page
Asked by DUDZIAK Krzysztof:

External web page needs to get a link to anchor placed on Confluence user home page.

Which is working format?

If following format needs to be used (found on <https://confluence.atlassian.com/conf74/anchors-1003128455.html>) how to find spacekey?

<http://myconfluence.com/display/spacekey/pagename#pagename-anchorname>


Answers:
author: Kishan Sharma
body: Hi [@DUDZIAK Krzysztof](/t5/user/viewprofilepage/user-id/4422045)

As per the example on the same link ++**DOCS**++ is the space key in below link - <http://myconfluence.com/display/>++**DOCS**++/My+page#Mypage-bottom

comments: author: DUDZIAK Krzysztof
body: Thanks for hint from you which I immediately tried out. Unfortunately it didn't help, anchor link placed to external web document does not open.

During this test I figured also out the Confluence article my anchor is placed to is addressable by URL of following form

[https://myconfluence.com/spaces/viewspace.action?key=\~usernick](https://myconfluence.com/spaces/viewspace.action?key=~usernick)

However, document opens also by URL this type [https://myconfluence.com/pages/viewpage.action?pageId=\<string of 9 digits\>]()

Hence it seems to be actually a space.I wonder if this is of any significance for anchor link type to choose.

How to understand 'My+page' and 'Mypage-bottom' tokens ? Maybe their values are wrong in my anchor link.


author: Kishan Sharma
body: I tried to add an external [link](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-labels/#api-wiki-rest-api-content-id-label-post) with an anchor on my confluence page and it is working as expected.

You are right, the link you pasted seems to be a link to space and not a page. The page link should be something like below -

<https://MYDOMAIN.atlassian.net/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor>


author: DUDZIAK Krzysztof
body: Thanks for hint.

How to understand the token '123456' , how does it distinct from 'TestPage' token?


author: Kishan Sharma
body: That number is a content ID created internally by confluence. If you open a page in confluence, simply copy the URL from the browser, it will be the url of your page.


author: DUDZIAK Krzysztof
body: Thanks for information.

Isn't 'TestPage' token in your url pattern the page name (or page title)?

Am I wrong in belief content ID and page name (page title) are unambiguously identifying Confluence document each? If my understanding is correct I wonder why two unambiguous document identifiers are needed in URL.

I am still on digging as my link in external web document to anchored Confluence is still not working. Currently I use link of following format [https://myconfluence.com/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor](https://mydomain.atlassian.net/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor)

whereby

123456 placeholder replaced with content -ID found in document url this format

<https://myconfluence.com/pages/viewpage.action?pageId=>\<string of 9 digits\>

and TestPage token replaced by document title normalized (underline chars instead of spaces).

---

I forgot also to mention there are special characters (at least one) in page title my anchor has been placed too - it is this way due to how Confluence is titling user home document. Possibly it is of significance here.


author: Kishan Sharma
body: Correct, "TestPage" is may page's title in confluence. So yes, the content ID and Page title are identifying the confluence page. I can use both to refer an anchor -
> <https://myconfluence.com/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor>

OR
<https://myconfluence.com/wiki/spaces/MYSPACE/pages/123456#anchor>  
From the [earlier page](https://confluence.atlassian.com/conf74/anchors-1003128455.html#Anchors-Step1), notes about the full URL:

* The page name is repeated in the URL, after the # sign. The second occurrence of the page name is concatenated into a single word, with all spaces removed.
* There is a single dash (hyphen) between the concatenated page name and the anchor name.
* The anchor name in the full URL is concatenated into a single word, with all spaces removed.
* The anchor name is case sensitive.
* If the page name contains special characters, where the URL displays a page ID rather than a name, the link to an anchor will look more like this <http://myconfluence.com/pages/viewpage.action?pageId=54689987#Test-page1!-anchor>   
  In this example the page title is `Test - Page 1!` and the anchor name is `anchor`.


author: DUDZIAK Krzysztof
body: Myself concludes from exchange made so far: if title line of Confluence document with my anchor includes single quote characters following forms of Confluence anchor url have no chance to work:

<http://myconfluence.com/display/spacekey/pagename#pagename-anchorname>

[https://MYDOMAIN.atlassian.net/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor](https://mydomain.atlassian.net/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor)

<https://myconfluence.com/wiki/spaces/MYSPACE/pages/123456/TestPage#anchor>

<https://myconfluence.com/wiki/spaces/MYSPACE/pages/123456#anchor>

[https://myconfluence.com/spaces/viewspace.action?key=\~usernick](https://myconfluence.com/spaces/viewspace.action?key=~usernick)

Instead I should concentrate on finding why following is not working

[https://myconfluence.com/pages/viewpage.action?](https://myconfluence.com/spaces/viewspace.action?key=~usernick)[pageId=54689987#Test-page-anchor](http://myconfluence.com/pages/viewpage.action?pageId=54689987#Test-page1!-anchor)

It is so easy to lose quickly overview over all degrees of freedom on composing url. Why must it be of that complication level?

If document with my anchor is also a space why can't I use spacename-oriented url scheme?

If document title and content id address document unambiguously **each** why need some schemes to have both?


author: Kishan Sharma
body: [https://myconfluence.com/pages/viewpage.action?](https://myconfluence.com/spaces/viewspace.action?key=~usernick)[pageId=54689987#Test-page-anchor](http://myconfluence.com/pages/viewpage.action?pageId=54689987#Test-page1!-anchor) --\> I have found this working for me.

We have freedom to choose name of the anchor but have to deal with the url created by confluence which is by design.

I would recommend raising it with [Atlassian Support](https://support.atlassian.com/contact/) as they can better explain these questions.


author: DUDZIAK Krzysztof
body: Thanks for input.
> [https://myconfluence.com/pages/viewpage.action?](https://myconfluence.com/spaces/viewspace.action?key=~usernick)[pageId=54689987#Test-page-anchor](http://myconfluence.com/pages/viewpage.action?pageId=54689987#Test-page1!-anchor) --\> I have found this working for me.

Is your document also user's home document (user's space), or rather deep on documents tree?


author: Kishan Sharma
body: Its not my home page but a document under some parent. However, the behavior is same irrespective of whether it is space's home page or any other page.


author: DUDZIAK Krzysztof
body: In such a case other constrains apply regarding document title / address. User home / space documents are guaranteed to have special characters in tittle. Only certain kinds of URL are working.


author: Kishan Sharma
body: Yes there might be cases where few special chars might affect the functionality. Do you have any examples of special characters with which you are having issues ? May be I can try replicating that and see if the behavior is same.


author: DUDZIAK Krzysztof
body: Isn't it that way Confluence is only party where user home / space document tittle scheme becomes defined? Isn't user nickname scheme's only parameter? If yes, scheme is expected to be commonly known. Scheme uses character "'" at one point in tittle.

I never had to set my Confluence home / space document tittle line on my own, Confluence did it kindly for me.


Tags: confluence-server

link

server

space

user