Confluence - search result for empty pages

Is there any way we could search for empty pages in Confluence? I don't want to create a User Macro to achive this. Is there any way of this being done using the search?

The Search Field page advises that you can search for body content.


2 answers

Hi Martin,

Simple answer: No, you can't search for empty pages using standard Confluence search.  These are the search plugins in the marketplace - one of them might have what you need.

Unfortunately, Confluence uses Lucene in the background for its search, which is not very good at finding empty fields (especially for tokenized fields, like contentBody. I know you said you didn't care for a user macro, but I figured I'd include one anyway. You can use it to search for text in a page (we used it to find link content), and I updated it so that if you search for "blankpage" (without the quotes) then it will find all blank pages. In addition, an icon is displayed next to the page title if the page has children, so that you can see the blank pages that are used as a "folder" and which ones are really orphaned pages.

## @noparams
#set ( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set ( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set ( $containerManager=$getInstanceMethod.invoke(null,null) )
#set ( $containerContext=$containerManager.containerContext )
#set ( $webResourceManager = $containerContext.getComponent('webResourceManager') )
#set ( $requestedSearch = "" )
#set ( $requestedSearch = $req.getParameter('requestedSearch') )
#set ( $requestedSpaces = "" )
#set ( $requestedSpaces = $req.getParameter('requestedSpaces') )
#set ( $requestCharacter = "?" )
#if ( $content.getUrlPath().contains("?") )
  #set ( $requestCharacter = "&" )
#if ( $requestedSearch == "" )
  <form class="aui top-label" onsubmit="return false;">
    <div class="field-group top-label">
      <label for="requested-search">Enter Search Terms:</label> 
      <input id="requested-search" class="text long-field" type="text" name="requestedSearch">
    <div class="field-group">
      <label for="requestedSpaces">Spaces to search:</label>
      <select class="select" id="requestedSpaces" name="requestedSpaces" multiple>
      #set ( $allSpaces = $spaceManager.getAllSpaces() )
      #foreach ( $space in $allSpaces )
        #if ( $space.isGlobal() )
          <option value="$space.key">$ - $space.key</option>
    <button class="button submit" onclick="window.location = '$content.getUrlPath()' + '${requestCharacter}requestedSearch=' + encodeURIComponent(document.getElementById('requested-search').value) + '&requestedSpaces=' + jQuery('#requestedSpaces').select2('val').join();">Search</button>
  #set ( $searchTerm = $requestedSearch )
  #foreach ( $spaceKey in $requestedSpaces.split(",") )
    #set ( $space = $spaceManager.getSpace($spaceKey) )
    <p> Pages containing $searchTerm in $ </p>
    #set ( $spacePages = $pageManager.getPages($space, true) )
      #foreach ($page in $spacePages)
        #set ( $pageMarkup = $page.getBodyAsString() )
        #if ( ($searchTerm == "blankpage" && $pageMarkup.trim() == "") || $pageMarkup.contains($searchTerm) )
                <a href="$action.getGlobalSettings().getBaseUrl()$page.getUrlPath()">$page.title</a>
                #if ( $searchTerm == "blankpage" && $page.hasChildren() )
                  <span class="aui-icon aui-icon-small aui-iconfont-group">has children</span>

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,008 views 2 13
Read article

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