Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to reference the label's link of a page in a user macro?


I want to show a page label within the content the same way as it appears at the bottom of the page. I got to the stage where the labels are displayed following this suggestion by Steve (, but the rendered labels are simple text, not hyperlinks. My code is the following:

## Macro title: Page labels
## Macro has a body: N
## Body processing: No macro body
## Developed by: Steve Behnke

## @noparams
#set($currentPage = $pageManager.getPage($content.getId()))
#set($pageLabels = $currentPage.getLabels())
#foreach( $labelObject in $pageLabels )
<span class="aui-label">$</span>

I guess the link element should go into the #foreach section, but I don't know how. Any help is much appreciated.


Many thanks,



1 answer

1 accepted

1 vote
Answer accepted

Hi @Peter_Baschan,

this should work:


 #foreach( $labelObject in $pageLabels )
<span class="aui-label">
<a class="aui-label-split-main" href="/label/$space.key/$" rel="tag">$</a>


Bill Bailey Community Leader Oct 02, 2018

Yes that should work. I built a similar structure for a macro recently.

Works like a dream. Many thanks! :)

Thomas Schlegel Community Leader Oct 03, 2018

You’re welcome, @Peter_Baschan

!! Thanks a lot to @Thomas Schlegel !!
I just introduced this nice little macro in our Confluence instance!

It will be very helpful!

Like Thomas Schlegel likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,474 views 7 29
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you