How to hide some specific products from google search engine

Topic summary

Goal: hide most products from Google, allowing only specific ones to be indexed.

  • Original approach: a Liquid conditional in the product template sets meta robots to “allow” for certain product handles (e.g., brown-shirt, black-shirt) and “noindex” for all others. This checks the product handle (URL slug) on product pages.
  • Feedback: while the code’s logic/syntax is sound, relying on the noindex meta tag may not fully prevent discovery/crawling. Suggested alternative: use Shopify Admin product visibility set to “Hidden” to remove products from the storefront and reduce indexing.
  • Alternative method: add a “noindex” product tag and use Liquid to detect the tag, then output a meta robots noindex tag. An image was shared showing where to add product tags; however, the provided code snippet only sets a flag and does not include the actual meta tag output.

Key terms:

  • Meta robots noindex: tells search engines not to index a page.
  • Product handle: unique URL-friendly identifier for a product.
  • Product template: Liquid theme file rendering product pages.

Status: open. A follow-up question asks where to paste the code; placement guidance and a complete snippet are still needed.

Summarized with AI on January 15. AI used: gpt-5.

Hello there, I have some products in my store. I want to hide all products instead of some.
I am using this code ==

{% if template contains ‘product’ %}
{% if product.handle == ‘brown-shirt’
or product.handle == ‘black-shirt’ or product.handle == ‘blue-shirt’
or product.handle == ‘red-shirt’ %}

{% else %}

{% endif %}
{% endif %}

is this code is perfect or not?
anyone code expert please help me?

The code that you have provided is a conditional statement that checks the handle of the product being viewed on the product template and determines whether to allow or disallow search engines to index it. This code is correct in terms of its syntax and logic, but it may not be the best approach for hiding products in your store.

One potential issue with this approach is that it uses the noindex meta tag to prevent search engines from indexing the products. This may not be the most effective method for hiding products, as search engines may still be able to discover and crawl the pages for these products.

A better approach for hiding products in your store would be to use the product visibility settings in the Shopify admin. This allows you to set the visibility of individual products to “Hidden” so that they are not shown on your storefront or search results. This will prevent customers from accessing the pages for these products and will prevent search engines from indexing them.

2 Likes

Hello @Muhammad-Jawad

You can add tags to products like this

And using this code

{% if template contains 'product' %}
{% assign no_index = false %}
{% for tag in product.tags %}
{% if tag contains 'noindex' %}
{% assign no_index = true %}
{% endif %}
{% endfor %}
{% if no_index %}

    
{% else %}

{% endif %}
{% endif %}

I hope the above is useful to you.

Kind & Best regards,
GemPages Support Team

1 Like

Where do you paste the code you suggested?