Add link to navigate to parent page
Asked by Brian Jones:

Is there a (easy) way to add a link to the current parent page that will continue to work after pages are rearranged in the hierarchy? I'm not sure we will be able to install a plugin. If we do install a plugin, it has to be rock solid.

Example: (Read \~ as whitespace)

A (parent of B)  
\|   
+-- B (parent of CD)  
\~\~\~\|  
\~\~\~+-- C (Child of B)  
\~\~\~+-- D (Child of B)

B has a link that navigates to A

CD have links that navigate to B

Then change happens, and the tree is re-organized to look like this:

A (parent of D)  
\|   
+-- D (parent of BC)  
\~\~\~\|  
\~\~\~+-- B (Child of D)  
\~\~\~+-- C (Child of D)

Now, without having to edit the pages...

BC's link navigate to D

D's link navigates to A


Answers:
author: Daniel Borcherding
body: Hello Brian,

You can use the Documentation theme to embed a page three macro on the left hand side of each page.

<https://confluence.atlassian.com/display/DOC/Configuring+the+Documentation+Theme>

This will give you a full page tree rendered on each of the pages of a space. It will include links to all descendants from the root of the space much in the matter you outline above.

Please let us know if that works for you.

comments: author: Brian Jones
body: I had forgotten about the docuemntation theme. While the space I'm using has the documentation theme on, it is too cluttered making it awkward to navigate. I may end up moving my pages to a new space since they are designed as a documentation collection.


author: Daniel Borcherding
body: Brain,

Pushing this idea a bit furhter I created the following feature request.

<https://jira.atlassian.com/browse/CONF-27737>

Supporting links to @\<locations\> may be a way to get the functionality you are looking for without the extra bulk of the documentation theme. If you think it is a good idea please give it a vote up in the upper right hand corner.


author: Stephen Deutsch
body: I was using the solution provided by Richard for a while, but unfortunately the page information tools hasn't been updated for the newest version of Confluence (not to mention that Confluence tries to update any wiki markup whenever it gets a chance).

After searching a bit, I finally found that you can make a simple user macro that will provide the same functionality.

```
## @noparams#contentLink2($content.getParent() false false)
```

Add a user macro, choose a name and title (I used linktoparent and "Link to Parent") and leave the rest of the options at the default values. Copy and paste these two lines into the macro body field and save, and it should work.

comments: author: David Grierson
body: This works really well but is only 99% complete. I've updated this with the following code instead: ## @noparams#if (!$content.getParent()) \<b\>No parent page found\</b\>#else #contentLink2($content.getParent() false false)#end


author: Evgeny Victorov
body: @David Grierson thanks a lot, you've just saved an hour of research for a single person, thousand hours for thousands of seekers!


author: Jim West
body: @David Grierson. I concur, thank you for this. Exactly what I was looking for.


author: Ronald Horner
body: Here is our solution. I will always display the name of the parent page and make it clickable. It will dynamically change no matter where you move the page to updating the parent link appropriately.

You'll need these macros:

* Page Information Tools Macro [https://marketplace.atlassian.com/plugins/com.adaptavist.confluence.pageinfo\</li\<\>\>](https://marketplace.atlassian.com/plugins/com.adaptavist.confluence.pageinfo%3C/li)
* [Linking Macro](https://marketplace.atlassian.com/plugins/com.adaptavist.confluence.pageinfo%3C/li)<https://marketplace.atlassian.com/plugins/net.customware.confluence.plugin.linking>

1. Click Edit on the page you wish to add the link
2. Click Insert -\> Wiki Markup
3. Insert some dummy wiki tags like {bogus}{bogus}
4. Click Insert
5. In the Wiki Markup panel remove the bogus tags
6. Insert the following wiki markup

```
{link-to:@parent}{page-info:title|page=@parent}{link-to}
```


author: vincent_marx_external
body: Hi,

If it can be useful:
>
> ```
> ## @param Title:title=Title|type=string|required=true|default=Go Back
> ## @param Style:title=Style|type=enum|required=true|enumValues=Primary,Standard|default=Primary
>
> #set($btnClass="")
> #set($txtColor="")
> #if($paramStyle == "Primary")
> #set($btnClass="aui-button-primary")
> #set($txtColor="color:white")
> #end
>
> #if (!$content.getParent())
> <b>No parent page found</b>
> #else
> <span>
> <a class="aui-button aui-button-compact $btnClass"
> style="position: absolute"
> title="$content.getParent().getTitle()"
> href="/pages/viewpage.action?pageId=$content.getParent().getId()"
> >
> <span class="aui-icon aui-icon-small aui-icon-small aui-iconfont-chevron-left-circle"></span>
> <span style="$txtColor">$paramTitle</span>
> </a>
> </span>
> #end
> ```

Preview:

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

Have a nice day,  
-- Vincent


author: CharlesH
body: The Reporting plugin would be one option here. It brings an "awareness" to the situation, so for instance, you could define a link on the current page which points at the parent page. This is not hard coded though, so if the page moves, then the link will point to the new parent.

```
{report-link:content:parent &gt; content:url|default=_This page has no parent._}View parent page{report-link}
```

More info here: <http://wiki.customware.net/repository/display/REPORT/report-link>

I can recommend this plugin. It is a commercial one, but the license cost is reasonable in my view.

An alternative approach could be to write a user macro, as I think the Confluence objects available in Velocity (user macro language) will allow you to identify the parent of the current page, and so create suitable links.

comments: author: Brian Jones
body: Charles--thanks for the pointer. I like the capability of the reporting plugin. I wish we had it!