You might have come across a situation where you want to hide a resource in Shopify from search engines, sitemaps and site search. The resource can be a page, a product, a collection or a blog post.
Shopify provides an easy way to do that. It is documented here. It’s pretty simple and can be done in under a minute.
The Scenario
We want to hide a product titled “Free hydration pack” in our Shopify store from search engines, sitemaps and site search. Here is how we are gonna do it.
Step 1: Creating a Metafield
Login to your Shopify Admin and do the following
- Click on the Settings in the left navigation sidebar and a popup will open.
- Select the Metafields on the settings sidebar.
- Select the resource where you want to add the metafield definition. In our case, we want to hide a product. So we selected Products from the list. If you want to hide a collection or a blog post, you will need to select the corresponding resource listed there.
- Click Add definition to create a new metafield with definition.
- Enter the Name of the metafield. It can be anything as you wish. We named the metafield Hide from search engines, sitemaps and site search.
- The Namespace and key field is the most important one. This field is automatically populated from the name which we added for the metafield. We will need to clear that and replace it with seo.hidden.
- Next comes the description field which is completely optional.
- Click Select content type and this will open a popup with a list of options to select.
- Select Integer from that list. By default, One Value integer is selected. Let that be as it is.
- Click on Save.
- That’s it.
Note: Once a metafield definition is created for a resource type(product in our case), it will be available on all the products. You don’t need to repeat this step when you want to hide another product. Just go to step 2 if you already did this.
Step 2: Adding value to the metafield
- Come back to Shopify Admin Dashboard. Click on Products in the left navigation sidebar.
- Select the product that you want to hide from search engines, sitemap and site search. In our case, it is “Free Hydration pack“
- Scroll to the bottom of the product page and you will find a section titled Metafields just below the Search engine listing preview section.
- You will find one or more metafields there. Select the one which we created. In our case we named the metafield as Hide from search engines, sitemaps and site search. Set its value to 1.
- That’s it.
The Results
Predictive Search: Before and After
As you can see above, the free hydration pack is not showing anymore in the predictive search box after the seo.hidden metafield is set to 1.
Site Search Results page: Before and After
As you can see above, the free hydration pack is not showing anymore in the search results page after the seo.hidden metafield is set to 1.
Sitemap: Before and After
As you can see above, the free hydration pack is not showing anymore in the sitemap after the seo.hidden metafield is set to 1.
Note: The product will still be visible on the all products page (The automated All collection / Products catalog page). One solution to fix that is to to add a new collection and name it All and select only the products that you want to show on the product catalog page.