Anyone familiar with Shopify knows that collections are a key part of organizing your product catalog. But managing your store effectively often means you need tons of collections, which can result in a lot of unnecessary pages being indexed by search engines. This can lead to issues like duplicate content or even cannibalization of your rankings in Google search results. Unfortunately, Shopify doesn’t offer an easy way for merchants to control which collections get indexed and which don’t. You can use the robots.txt file or opt for paid apps, but here’s our approach – simple, cost-effective, and no messy SEO consequences.
Our method is super easy and can be implemented by anyone. With just a little code and metafields, you’ll be able to control which collections shouldn’t be indexed. Here’s how:
Now that we’ve set up the metafield, it’s time to add some code. Don’t worry, it’s easy. Here’s what to do:
{% if collection.metafields.custom.noindex == true %}
<meta name=”robots” content=”noindex, follow”>
{% endif %}
This is a basic check if the metafield value is True. If it is, it will add a noindex tag to the page’s head, telling search engines not to index that collection. We recommend using follow instead of nofollow because it tells bots to follow links on the page. If you used a different Namespace and key when creating your metafield, just change the code here to match:
collection.metafields.custom.yourname
Save the changes, and you’re done.
Now all you need to do is activate this metafield on the collections you want to hide from search engines, and they won’t get indexed anymore. You can now create hidden collections freely, without worrying about them showing up in search results.
You can use a similar approach for your products by creating a similar metafield. Just add an extra block of code, and use the following:
{% if collection.metafields.custom.noindex == true %}
<meta name=”robots” content=”noindex, follow”>
{% endif %}