I have a handful of ACTIVE products that I want to hide from those who visit my website when using the search feature to find items with keywords that would appear in product titles or description. At the same time I do not want to use SEO.HIDDEN metafield designation because I WANT to keep those hidden items active for Goggle indexing. I want prospective new customers to find those items via Google search but NOT to be found by someone already on the website using Shopify search bar.
Topic summary
Goal: Keep certain products indexable by Google while hiding them from the Shopify storefront search results.
Proposed approach:
- Add a product tag (e.g., “hidden-from-search”).
- Modify the search results Liquid template to skip items with that tag using a conditional inside the search loop (continue when item is a product and has the tag).
Implementation details and issues:
- A code sample was provided (Liquid) to filter items by tag during iteration of search.results. The snippet likely needs to be placed inside the existing {% for item in search.results %} loop, before rendering each result include.
- The original poster encountered save-time errors after inserting the snippet and requested help integrating it into the Minimal theme’s search.liquid. (Potential syntax/placement issues; code correctness is central.)
Open questions:
- How to adjust search.results_count so it excludes hidden products; a participant asked about deducting the count of tagged products, but no solution was provided.
Status: No confirmed resolution yet. Liquid template edits and handling of the results counter remain outstanding. Code snippets are central to this discussion.
Did you try to add a special/custom tag into a product that you want to hide on the Shopify search bar, then use a custom code not to show it on the result page?
Hi,
Hope this will help
Add a tag “hidden-from-search”.
Modify the Search Results Template
{% assign hidden_tag = 'hidden-from-search' %}
{% if search.results.size > 0 %}
{% for item in search.results %}
{% if item.object_type == 'product' and item.tags contains hidden_tag %}
{%- continue -%}
{% endif %}
## {{ item.title }}
{% endfor %}
{% else %}
No results found
{% endif %}
Thank you for the suggestion, appas very practical. Just unsure of how and where to incorporate the code you offer within my current search liquid below. Can you assist?
{% comment %}
The {{ content_for_header }} in theme.liquid will output the following stylesheet just for this page:
It has a few helpers in there, but this theme writes its own styles so there
are no dependencies or conflicts. You can ignore that file.
Return only products or pages in results:
- http://docs.shopify.com/manual/configuration/store-customization/return-only-product-in-storefront-search-results
- Or manually add type=product or type=page to the search URL as a parameter
{% endcomment %}
{% comment %}
If you’re only showing products with the method above, why not show them off in a grid instead?
Set grid_results to true and see your updated results page for the new layout.
{% endcomment %}
{% assign grid_results = false %}
{% comment %}
Check to enforce respond.js
{% endcomment %}
{% assign respond_js_secret_key = shop.domain | md5 %}
{% unless search.terms == respond_js_secret_key %}
{% if search.performed %}
{% comment %}
Avoid accessing search.results before the opening paginate tag.
If you do, the pagination of results will be broken.
{% endcomment %}
{% paginate search.results by 10 %}
{% comment %}
We don’t have any results to show. Feel free to show off featured products
or suggested searches here.
{% endcomment %}
{% if search.results_count == 0 %}
{{ 'general.search.no_results_html' | t: terms: search.terms }}
{% else %}
{{ 'general.search.results_for_html' | t: terms: search.terms }}
{% comment %}
Each result template, based on the grid_layout variable above
{% endcomment %}
{% if grid_results == false %}
{% for item in search.results %} {% include 'search-result' %}
{% endfor %}
{% else %}
{% endif %}
{% endif %}
{% if paginate.pages > 1 %}
{% endpaginate %}
{% else %}
{% comment %}
If search.performed is false, someone either accessed the page without
the q parameter, or it was blank.
Be sure to show a search form here, along with anything else you want to showcase.
{% endcomment %}
{{ 'general.search.title' | t }}
{% endif %}
{% else %}
{% include ‘respond’ %}
{% layout none %}
{% endunless %}
I have inserted the code you provided into my current “search liquid” (Shopify Minimal Theme) however upon saving I am encountering errors in which recommendations are being made to revise the existing code. My familiarity with coding in very basic at best, so I am not comfortable in making serveral revisions.
Any suggestions I can follow
Hi, we are able to filter out the products from the search result, but we notice that the search.results_count still counts this hidden product. Do you have a suggestion how we can also deduct the hidden number of products from the counter? Like I am thinking of a piece of code which counts the total number of products tagged with hidden-from-search and deduct this from the search.products_count?