How to hide unwanted items from Squarespace search results

Every Squarespace site has a built-in search function that anyone can access by adding a /search to the end of your domain. You can use this page as an internal tool to quickly find site content, or you can use it to create a public search page.

The only problem, is that this search function finds all content, not just pages or blog posts. It finds images and attachments too!

There’s an easy to use checkbox on the settings of every page (or collection) to enable you to hide the content from search engine results, but this option doesn’t extend to the results of the internal search page.

So what can you do to hide unwanted search results on the Squarespace search page?

Hiding content types from search results

One option is to add some CSS to Design > Custom CSS, to hide certain types of content. I’ve provided some suggestions below. You can add one of more of these to match your needs.

For example to hide images, add this:

/* Hide IMAGES that match search criteria */
.search-result .sqs-search-container-item.sqs-post.sqs-post-type-image.ContentItem.sqs-search-page-item {
  display: none;
}

To hide attachments (like PDFs you’ve added to your site), add this:

/* Hide ATTACHMENTS that match search criteria */
.search-result .sqs-search-container-item.sqs-post.sqs-post-type-attachment.ContentItem.sqs-search-page-item {
  display: none;  
}

To hide blog posts, add this:

/* Hide BLOG POSTS that match search criteria */
.search-result .sqs-search-container-item.sqs-search-page-item.sqs-post.ContentItem {
  display: none;  
}

You could hide normal pages using the code below, but that would be very unusual!

/* Hide PAGES that match search criteria */
.search-result .sqs-search-container-item.sqs-post.PageCollectionData.sqs-search-page-item {
  display: none;  
}

Remember that if you want to limit the search results to one content collection, like a blog, there’s also a Search Block that you can use instead.

SF Digital