How to define a link that includes the Base URL of the current instance?
Asked by Normand Brousseau:

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:

```
&lt;a href="../../users/viewmylabels.action"&gt;My labels&lt;/a&gt;
```

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:

```
&lt;a href="../users/viewmylabels.action"&gt;My labels&lt;/a&gt;
```

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

Thanks,  
Normand


Answers:
author: Bruna Griebeler
body: 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!

comments: author: Normand Brousseau
body: 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}&lt;a href="/users/viewmylabels.action"&gt;Click here&lt;/a&gt; to see &lt;b&gt;your own&lt;/b&gt; 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!


author: Normand Brousseau
body: And... another step further?

I've found the following syntax:

```
&lt;a href="../../users/viewmylabels.action"&gt;My labels&lt;/a&gt;
```

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:

```
&lt;a href="../users/viewmylabels.action"&gt;My labels&lt;/a&gt;
```

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


author: Normand Brousseau
body: 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


author: Normand Brousseau
body: 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?


Tags: confluence-administration