How to define a link that includes the Base URL of the current instance?

I wonder how to define a relative URL which would trigger a Confluence action within the current instance.

An example:

  • if I have the two following Base URLs:
    • for our PROD instance = [https://www.ourplace.com/confluence]
    • for our DEV instance = [https://www.ourplace.com/confluence-dev]
  • I would like the link to display the user's personal labels ("my:")
  • the relative link would be something like: users/viewmylabels.action
  • the output would depend on the instance:
    • in PROD = [https://www.ourplace.com/confluence/users/viewmylabels.action]
    • in DEV = [https://www.ourplace.com/confluence-dev/users/viewmylabels.action]

Of course, I could also apply the same recipe to many administrative actions within documented procedures.

While experimenting, I've found the following syntax:

<a href="../../users/viewmylabels.action">My labels</a>

However, it will work only when there are no international chars in the page title.

When international chars are found in the page title, the URL used for display resembles the following:

https://our_base_url/confluence/page/viewpage.action?pageId=32802766

Therefore, the Base URL is only "one relative level back", and the syntax must be changed to this:

<a href="../users/viewmylabels.action">My labels</a>

Is there a "Base URL" syntax that works regardless of the page title?

Thanks,
Normand

2 answers

1 accepted

Hi Normand,

I believe Confluence by default will not allow the relative link to be placed on the page, unless you create the link using html code.

However to use html code on a page, you must enable the module html macro on the add-ons page: https://confluence.atlassian.com/display/DOC/Enabling+HTML+macros

Hope it helps!

Hi Bruna, Wie get's?

YES, your answer is very useful. Would you allow me to take it one step further?

I've activated the HTML macro in our TEST instance, and I want to include a link to display all "personal" (my:) labels created by the current user in the current instance.

Let's say the TEST instance Base URL is [https://www.ourplace.com/confluence-TEST] and the PROD instance Base URL is [https://www.ourplace.com/confluence]. I want the link to point to the user's own {{my:labels}} listing of the confluence-TEST instance if he's browsing there, but of the confluence (PROD) instance if he's in PROD. (I refresh our TEST instance just by reloading the PROD data, so the same link will be used.)

So far I've tried a syntax such as the following:

{html}
<a href="/users/viewmylabels.action">Click here</a> to see <b>your own</b> labels.
{html}

But the resulting link I'm getting does NOT include the instance name, i.e. "confluence-TEST" or "confluence", so I don't have the FULL Base URL.

Do you know what syntax should be used to yield the link, prefixed with the COMPLETE Base URL (i.e. $BASEURL/users/viewmylabels.action)?

Thanks!

And... another step further?

I've found the following syntax:

<a href="../../users/viewmylabels.action">My labels</a>

However, it will work only when there are no international chars in the page title.

When international chars are found in the page title, the URL used for display resembles the following:

https://our_base_url/confluence/pages/viewpage.action?pageId=32802766

Therefore, the Base URL is only "one relative level back", and the syntax must be changed to this:

<a href="../users/viewmylabels.action">My labels</a>

Is there a "Base URL" syntax that works regardless of the page title?

Sorry about the delay, I'm not too familiar with Atlassian Answers and karma management, so I'm not sure I'm treating this one properly...

I'm going to accept Bruna's answer (hope she gets her karma points!), which helped me a great deal forward (with the html macro) -- however, I still have no answer to my last question concerning the "relative link" topic.

Thanks anyway.

Normand

I'm sorry I had to repeat my comment into the initial text, but my question has now slightly changed since I've been experimenting in parallel.

I still appreciate Bruna's previous answer (which was completely useful), but my solution is still incomplete.

Or maybe I don't understand how Atlassian Answers works -- maybe there's no good karma for completing an answer?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

639 views 21 11
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you