How can I hide a product from Shopify Search bar but keep active with SEO Google indexing

How can I hide a product from Shopify Search bar but keep active with SEO Google indexing

cmt6891
Visitor
3 0 0

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.  

Replies 5 (5)

JinAlkaid
Shopify Partner
8 1 1

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?

Jin Alkaid: A Seasoned Shopify Developer

Small_Task_Help
Shopify Partner
830 28 75

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 %}
  <div class="search-results">
    {% for item in search.results %}
      {% if item.object_type == 'product' and item.tags contains hidden_tag %}
        {%- continue -%}
      {% endif %}

      <!-- Your existing code for displaying search results -->
      <div class="search-result-item">
        <h2>{{ item.title }}</h2>
        <!-- Add more product details here -->
      </div>
    {% endfor %}
  </div>
{% else %}
  <p>No results found</p>
{% endif %}

 

To Get Shopify Experts Help, E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert Agency
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad
cmt6891
Visitor
3 0 0

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:
- <link rel="stylesheet" href="/global/search.css" type="text/css">

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-s...
- 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 %}

<div class="section-header section-header--large">
<h1 class="section-header__title h2">{{ 'general.search.no_results_html' | t: terms: search.terms }}</h1>
</div>
{% include 'search-bar' %}

{% else %}

<div class="section-header section-header--large">
<h1 class="section-header__title h2">{{ 'general.search.results_for_html' | t: terms: search.terms }}</h1>
</div>
{% include 'search-bar' %}

{% comment %}
Each result template, based on the grid_layout variable above
{% endcomment %}
{% if grid_results == false %}

<hr>
{% for item in search.results %}
{% include 'search-result' %}
<hr>
{% endfor %}

{% else %}

<div class="grid-uniform">
{% for item in search.results %}
{% assign grid_item_width = 'post-large--one-quarter medium--one-third small--one-half' %}
{% include 'search-result-grid' %}
{% endfor %}
</div>

{% endif %}

{% endif %}

{% if paginate.pages > 1 %}
<div class="text-center">
{% include 'pagination-custom' %}
</div>
{% endif %}

{% 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 %}
<div class="section-header section-header--large">
<h1 class="section-header__title h2">{{ 'general.search.title' | t }}</h1>
</div>
{% include 'search-bar' %}

{% endif %}

{% else %}
{% include 'respond' %}
{% layout none %}
{% endunless %}

cmt6891
Visitor
3 0 0

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

owb
Visitor
1 0 0

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?