How do I exclude all attachments (images, pdfs, etc.) from both the global and space-level search in Confluence?

I can't find any information online about customizing the Confluence search to exclude images and all other attachments. I know that users can set a filter on the advanced search page, but I'd like the default search to return only pages (no images, other attachments, blogs, etc.).

I'd appreciate any and all ideas.



2 answers

1 accepted

0 votes
Accepted answer
Davin Studer Community Champion Jun 26, 2014

You can exclude attachments from being indexed. Here is the documentation for that.

Thanks, Davin. I've looked through that document before. It seems to be about excluding Word, PowerPoint, Excel, and PDF files, but I'm interested in excluding all images as well. Is that also possible by editing the atlassian-plugin.xml?

Davin Studer Community Champion Jun 29, 2014

Do you want users to not ever be able to search for these, or just not by default using the top right search box? If you just want to make sure that the top right search bar will by default only show pages then you can add this Javascript to the global custom html. This will put in a hidden field in the form element of the top right search box that says to only return pages.

	AJS.$('#quick-search').append('<input type="hidden" name="type" value="page">');

This is exactly what I was looking for. Thanks very much, Davin! It works perfectly for the global search.

I tried to apply this to the search box in the pagetree area (documentation theme) but didn't have any luck. Instead, I hid the default search box in the space stylesheet and configured the doc theme to include the {search-box} macro, which lets me filter by type.

I tried this too and it seemed to do nothing. Did you apply the custom html to header, body, or footer?

Davin Studer Community Champion Dec 09, 2014

It should be in the after body section. Also, you need to wrap it in script tags. <script type="text/javascript"> AJS.toInit(function(){ ... }); </script>

David, I found a solution for filtering page tree search results. A bit of a hassle, but it works.

In each space, we did the following:

1. We configured the Documentation theme (Browse > Space Admin > Themes Configure them), adding a custom search macro to the page tree area. We also used the html macro to tag the search box with an html id, so that we can target it in the space styesheet.

{html}<div id="customsearchbox">{html}



2. We editing the space stylesheet (Browse > Space Admin > Stylesheet) to hide the default search box and apply our styling to the custom search box:

Space-specific search box
Default search box is hidden; custom is 
included in the doc theme
#pagetreesearch {
    display: none;
#customsearchbox {
   margin: 10px 0 10px 20px;
   min-width: 230px;
#customsearchbox form.confluence-searchbox.adaptavist-searchbox {
   white-space: nowrap;
   margin: 1.5em 0 0 0;
   position: relative;
#customsearchbox input[type=text],
#customsearchbox input[type=submit] {
   margin: 0 8px 8px 0;
   border: 1px solid #CCCCCC;
   color: #666666;
   max-width: 165px;
   padding: 4px 5px;
   height: 2.14285em;
   line-height: 1.4285;
   box-shadow: inset 0 1px 3px #CCC;
   width: 100%;
   border-radius: 3.01px;
   font-size: inherit;
   font-family: 'Open Sans', Arial, sans-serif;
   box-sizing: border-box;
#customsearchbox input[type=submit]{
   background: #f2f2f2;
   background: -moz-linear-gradient(top,#fff 0,#f2f2f2 100%);
   background: -ms-linear-gradient(top,#fff 0,#f2f2f2 100%);
   background: -o-linear-gradient(top,#fff 0,#f2f2f2 100%);
   background: -webkit-linear-gradient(top,#fff 0,#f2f2f2 100%);
   background: linear-gradient(top,#fff 0,#f2f2f2 100%);
   text-decoration: none;
   text-shadow: 0 1px 0 white;
   vertical-align: baseline;
   min-width: 0;
   width: auto;
   box-shadow: none;

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

784 views 33 5
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