Hide a Product from Search Engines Using Metafields
Have you ever wanted to hide a product from being indexed? I have
Did you know you could do that using a metafield?! Me neither.
Check this out.
All you need to do is create a new metafield for your products.
The new metafield needs to have the following attributes:
- "namespace" : "seo"
- "key" : "hidden"
- "value" : "number_integer"
Whenever you set the value of this metafield to 1 for a product it will cause noindex and nofollow meta tags to be added to the product page.
You can verify the metatags are in place with a simple query.
For example, requesting a product id for a product where you have set this tag will result in something like:
https://mystore.myshopify.com/admin/products/12345/metafields.json
{
"metafield": {
"namespace": "seo",
"key": "hidden",
"value": 1,
"type": "number_integer"
}
}
This works for any resource that supports metafields, not just products. You can use this same technique with Articles, Blogs, Pages, etc.