Normally you want to have your products show up in Google. But every now and then you might want one to be hidden.
For example, maybe there's a special version only for a specific reseller or maybe your supplier doesn't allow you to advertise a product at all.
That's the problem Dan had, he wanted to keep a few products out of the search results.
To do that you can use what's called a robots HTML tag with the
noindex content (also called a noindex tag, though that's not the correct technical term). This tag tells Google to not index the page, where the index is the search results.
You can easily add this HTML tag to your theme's template but if you do, you might block all pages. Probably not what you want...
Thinking about it, there are three ways to make this work.
- Edit your
layout/theme.liquidfile and add the tag only for a specific product handle:
Replace THING with the handle of the product you want to hide.
- Add a metafield for the product and edit your
layout/theme.liquidfile to look for that metafield:
This code is looking for a metafield on the product in the
seo namespace and using the
content key. In that key you can put whatever you want for the robots tag, in this case putting
noindex will create the noindex tag to hide a product.
- Use an app, which might be overkill if you only have one or two products to hide.
Of the three options #2 is the most flexible and can work on any number of products, but takes the most work to document and code (and remember).
Option #1 is great if you only have one or two products you want to hide.
Using an app could be the easiest if you can find an app that doesn't mess with other parts of your store and is priced reasonably.
The end result of all three is the same, Google sees that tag and they remove that product page from their search results.
Another great optimization for your store is to make sure your product's structured data is setup correctly for Google's Rich Snippets. With those you'll get more traffic and better converting traffic.
You can either audit your store's structured data by hand or install JSON-LD for SEO and have all the structured data you need.
It's already helping a few thousand Shopify stores with their structured data and it could help you too.