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.