How to remove specific pages from storefront search results

Topic summary

A user needed to hide internal pages (containing size guides and text snippets) from their Shopify storefront search while keeping them accessible for product templates. Initial attempts using the seo.hidden metafield failed to affect storefront search results.

Working Solution:

  • Create a custom metafield for pages (e.g., hide_from_storefront_search) with integer values 0-1
  • Modify main-search.liquid by wrapping the search results list item (<li class="grid__item">) with an {% unless item.metafields.custom.hide_from_storefront_search == 1 %} condition
  • Set the metafield to “1” for pages to hide

Key Implementation Detail:
The {% unless %} tag must wrap the entire <li> element (not just the loop start) to prevent empty grid spaces where hidden results would appear.

Known Bug:
The search results counter still includes hidden pages in the total count, showing “5 results” when only 4 are visible. This cosmetic issue hasn’t been resolved.

Status:
Solution confirmed working on Dawn 6.0.2 and Studio theme (version 10.0.0), though one user reported it stopped working after updating Studio to version 11.0.0.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hello @VrVa ,

To fix this issue you need to follow the below-provided steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme you want to edit, and then click Actions > Edit code.

  3. Click the theme.liquid layout file.

  4. To exclude the search template, paste the following code in the section:

{% if the template contains ‘search’ %}

{% endif %}

  1. To exclude a specific page, paste the following code in the section:

{% if handle contains ‘page-handle-you-want-to-exclude’ %}

{% endif %}

Hope this will resolve your issue. Let us know if any more help is needed.

Regards,

CedCommerce