How can I create a Confluence user macro that displays the full Confluence page path?
Asked by Gerardo Rigo:

We have Confluence Server 6.9.1


Answers:
author: Davin Studer
body: What do you mean by that? The page the macro is on? A page selected in the macro properties?

comments: author: Gerardo Rigo
body: Yes, the page the macro is on. Thank you for reading my post.


author: Davin Studer
body: This will put the url on the page wherever you put the macro.

**Macro Name:**   
page_url

**Macro Title:**   
Page URL

**Macro Body Processing:**   
No macro body

**Template:**

```
## @noparams$settingsManager.getGlobalSettings().getBaseUrl()$content.getUrlPath()
```


author: Gerardo Rigo
body: Thank you Davin. We want the macro to put the path in Confluence not the url, e.g.: Parent Page Title/Child Page Title/Child Page Title...


author: Davin Studer
body: Ah, got it. This should work.

**Macro Name:**   
path_to_page

**Macro Title:**   
Path to Page

**Macro Body Processing:**   
No macro body

**Template:**

```
## @noparams#set($breadcrumbs = "")#set($breadcrumbSeperator = " / ")#getBreadcrumbs($content.id)$breadcrumbs##recursive macro to get the path to page breadcrumbs#macro( getBreadcrumbs $contentID )    #set($thePage = $pageManager.getPage($contentID))        #set($breadcrumbs = $thePage.getTitle() + $breadcrumbs)        ## Does this iteration have a parent?    #if($thePage.getParent())        #set($breadcrumbs = $breadcrumbSeperator + $breadcrumbs)                ## Get parent of this iteration        #getBreadcrumbs($thePage.getParent().getContentId().asLong())    #end#end
```


author: Gerardo Rigo
body: Works. Thank you! Is there a way to insert this path in the global footer, so we do it only once for all pages.


author: Davin Studer
body: If you want to do it on a space by space basis you can go to Space tools -\> Look and Feel -\> Sidebar, header and footer you can put in wiki markup in the foot like such ...

```
{path_to_page}
```

Or if you want to do it on a global basis in Confluence Admin -\> Look and Feel -\> Layouts you can put the macro in the Page Layout decorator and it will show up on every page. FYI, this methods also can work on a space by space basis it is just a bit more complex than the above option. It is in Space tools -\> Look and Feel -\> Layout. Layout changes made in the space layout will override global layout changes.

**Look for ...**

```
        <div id="main-content" class="wiki-content">           $body        </div>
```

**And change it to ...**

```
        <div id="main-content" class="wiki-content">           $body           $helper.renderConfluenceMacro("{path_to_page}")        </div>
```


author: Gerardo Rigo
body: Very useful. Thanks!


author: mykhailo m
body: Dear [@Davin Studer](/t5/user/viewprofilepage/user-id/781467) ,

Thank you a lot for the example!

If I understand right this macro provides breadcrumb only for created page.

Don't you know, is it possible to modify this macro to insert such path for linked article on Confluence. For example I create a new page on Confluence and want insert link (currenly there are three options: **Display URL** , **Display as link** , **Display as card** ). So I think of which will allow to insert link and **Display** it **as path (breadcrumb)**.

as example (let's say it is a confluence article) which I want refer to: <https://support.atlassian.com/confluence-cloud/docs/insert-links-and-anchors/>  
And it would be great to get the following path in newly created article with path to another article "Insert links":

* Display as **path** (aka breadcrumb, [Atlassian Support](https://support.atlassian.com/)/[Confluence](https://support.atlassian.com/confluence-cloud)/[Resources/](https://support.atlassian.com/confluence-cloud/resources/)[Create and organize work in Confluence](https://support.atlassian.com/confluence-cloud/docs/create-and-organize-work-in-confluence-cloud/)/[Create and edit content](https://support.atlassian.com/confluence-cloud/docs/create-and-edit-content/)/)
* Display as **full path** (aka
* [Atlassian Support](https://support.atlassian.com/)/[Confluence](https://support.atlassian.com/confluence-cloud)/[Resources/](https://support.atlassian.com/confluence-cloud/resources/)[Create and organize work in Confluence](https://support.atlassian.com/confluence-cloud/docs/create-and-organize-work-in-confluence-cloud/)/[Create and edit content](https://support.atlassian.com/confluence-cloud/docs/create-and-edit-content/)/[Insert links](https://support.atlassian.com/confluence-cloud/docs/insert-links-and-anchors/)

Thank you in advance!


author: mykhailo m
body: Dear [@Davin Studer](/t5/user/viewprofilepage/user-id/781467)

I did not know, that macro is available only for stand alone version of Confluence. And I looked for such possibility but for Cloud version.

So I am sorry for disturbing you.

Best wishes,

Mykhailo.


Tags: user-macro