Find pages without labels

Hi out there,

is there an easy way to find all pages without a label? I know there is a macro for content by label and it is possible to exclude labels but right now we have nearly 160 labels and I do not want to add them all to the macro.

Thanks,

Bruce

1 answer

1 accepted

This is possible by writing a usermacro that iterates over all spaces and its pages searching for pages without a label. But such a usermacro will slow down your system dependent on how big your confluence instance is. Such a macro should only be shortly used by an administrator.

Here is the usermacro code.

## @noparams

## DO NOT USE THIS MACRO ON A LOT OF PAGES BECAUSE OF PERFORMANCE ISSUES. IT DEFINITELY WILL SLOW DOWN YOU SYSTEM!!!!!

#set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
  
## the pageManager gives you access to the pages
#set($pageManager =$containerContext.getComponent('pageManager')) 

## the spaceManager gives you access to the spaces
#set($spaceManager =$containerContext.getComponent('spaceManager')) 
  
##over all spaces (WARNING THIS COULD TAKE SOME TIME ON BIG CF INSTANCES )
#foreach( $space in $spaceManager.getAllSpaces() )   

    <b>Unlabeled pages in space $space.name<b>
    <ul>
    ##over each page in the current space ( WARNING THIS COULD TAKE SOME TIME ON BIG CF INSTANCES)
    #foreach( $page in $pageManager.getPages( $space, true) )   

        #if( $page.labels.size() == 0 )
               <li><a href="$req.contextPath$page.urlPath">$page.title</a></li>
        #end
    #end
    </ul>
#end

Testet with my Confluence 4.0.

Thanks, I will try that

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

374 views 20 10
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