How to include full URL in a page
Asked by J W:

I would like to include the full URL to a page in the page itself. The reason for this is that we export page to word and forward this exported word document to downstream systems.

I would like to include the link to the page in confluence to be able to close the loop. If any fault or comment is needed it would be easy for the once using the word-doc to select the link and get directly to the source information and change/comment on the page in question. This is why I need the full long URL to the page.

The person writing the page in Confluence could of course type in the URL manually but users often forget/type the wrong URL or forget to update if they change the page title so I want an automatic way to do this.

I wrote a small JavaScript to get the page URL and insert it which works well in Confluence but the information is not included in the exported version for some reason. (not in word nor in pdf).

My question is if there exist either a Confluence native way to do this or how I would get the exported document to include the result of the URL.

The JavaScript I use (inside a HTML Marco) is:

![JS.PNG](/t5/image/serverpage/image-id/261267iD5FCF3AB48011BDC/image-size/large?v=v2&px=999 "JS.PNG")


Answers:
author: Barbara Szczesniak
body: [@J W](/t5/user/viewprofilepage/user-id/5235384)

I have the Cloud version, but there I can:

1. Insert a link and select the current page
2. Modify the link to show the URL

![LinkTypeisURL.png](https://community.atlassian.com/t5/image/serverpage/image-id/261392i407EEC8B72637CE2/image-size/large?v=v2&px=999 "LinkTypeisURL.png")

Would this not meet your needs? Maybe I am misunderstanding what you are trying to achieve. I would hope this type of link is updated when the name of the page is changed, but I have not tested this.

comments: author: J W
body: Thank, I use a server based instance and a similar function exists and works to insert a link but when inserting it as a full URL is will not get updated.

Creating a link where the page name is used the link and ref is update if the page name change but with the same problems as with my solution. When exporting to word (and pdf) the URL is no exported correctly. This is apparently a known problem, see [Links to Confluence when exporting to PDF/Word (atlassian.com)](https://community.atlassian.com/t5/Confluence-questions/Links-to-Confluence-when-exporting-to-PDF-Word/qaq-p/660559).

It seems I need to either need to use the manual approach and hope people can follow instructions or I make a script that enhances the export and inserts the page url when the page is exported.


author: Thomas Schlegel
body: Hi [@J W](/t5/user/viewprofilepage/user-id/5235384) ,

you can do that with a user macro. The following code will print the URL of the page on the page itself, if you put your usermacro on the page:

$settingsManager.getGlobalSettings().getBaseUrl()$content.getUrlPath()

comments: author: J W
body: Thanks, unfortunately I do not have sys admin right on our installation. We have a large server based installation with many spaces and the sys admins are centralized. I will try to convince them to let me test this on our dev version.


author: Thomas Schlegel
body: Good Luck, [@J W](/t5/user/viewprofilepage/user-id/5235384) !


Tags: confluence-server

server