I have this same issue. I like that this solution hides my pages from storefront search, but it will still write “3 results” despite showing 0 results. Does anybody know how to modify the code to reflect the new amount of 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.liquidby 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.