Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to include full URL in a page

J W June 5, 2023

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

2 answers

0 votes
Barbara Szczesniak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2023

@J W 

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

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.

J W June 7, 2023

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).

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. 

0 votes
Thomas Schlegel
Community Champion
June 5, 2023

Hi @J W ,

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()

J W June 7, 2023

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.

Thomas Schlegel
Community Champion
June 7, 2023

Good Luck, @J W  !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events