How do I properly use canonical tag in a shopify page?

Solved

How do I properly use canonical tag in a shopify page?

surfingcinv
Excursionist
39 1 12

Hello,

 

Using Dawn 13.0, no custom theme, all default store build.

 

I have built a structure of simple shopify pages.  Around 75 or so. I need to point them all to the parent page, which is the only relevant page to be indexed (duplicate data on the others(SEO)).

 

Parent page to index:

https://www.iamgreenminded.com/pages/shade-selector

 

75 pages to point canonical to parent above, look like this:

https://www.iamgreenminded.com/pages/shade-selector-medium-light

https://www.iamgreenminded.com/pages/shade-selector-mediumlight-olive

 

2 questions: 

 

1. I understand using the canonical syntax on these pages would be best practice?   <link rel="canonical" href="https://www.iamgreenminded.com/pages/shade-selector/" />

Other option I hear is robots?

 

2. If canonical is the correct option , I assume I need to put this in the head of the pages

how do I do this properly on shopify? 

 

Thank you.

 

 

 

 

 

 

Accepted Solution (1)

tim
Shopify Partner
3764 351 1384

This is an accepted solution.

Nope. These pages have different content, so canonical is not applicable here. Canonical is used for pages with identical content.

For example -- when product belongs to 5 collections there are 5 collection-aware URLs pointing to this product page and one collection-less link. But the product page is the same -- this is where you'd use canonical.

 

See https://www.semrush.com/blog/canonical-url-guide/ 

 

If your want to hide those pages from search bots, then yes, you can use robots.txt, or, alternatively, you can set a metafield on these page objects.

Check https://community.shopify.com/c/shopify-discussions/hide-a-product-from-seo-and-from-the-shopify-fro... -- it talks about products, but you can do the same with pages.

 

When metafield is set to 1, these pages

  • would not be included in your sitemap (modifying robots.txt would not do it and Google will complain about "page in index, but disallowed by robots"
  • would set <META NAME="robots" CONTENT="noindex,nofollow"> in the head of this page (kinda equivalent to disallow in robots.txt)
  • not shown by site own search

And no need to modify your theme.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Replies 6 (6)

theycallmemakka
Shopify Partner
1661 396 416

Hi @surfingcinv ,

 

Using canonical tags is indeed the best practice in this scenario. Canonical tags inform search engines that a particular page is the preferred version among a set of duplicate pages, ensuring that your SEO efforts are concentrated on the parent page.

 

This seems to be a custom request. We can make the use of metafield to store canonical tags for each page. For this we will have to make changes on the theme. Do you have any experiance creating a meta field? If yes, I can provide a step by step instrutions on how to get this done.

 

Thank you

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

pawankumar
Shopify Partner
592 83 102

Hi @surfingcinv 
You can add this code before closing head tag </head>

{% if page.handle contains "shade-selector" %}
<link rel="canonical" href="https://www.iamgreenminded.com/pages/shade-selector/" />
{% endif %}

It will set same canonicals to all pages that has shade-selector in handle
For more advance conditions, You can use metafields
Please check if it is helpful to you
Thanks!

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan
surfingcinv
Excursionist
39 1 12

Great. Can you tell me where/what file to put this code in?

 

pawankumar
Shopify Partner
592 83 102

Please put in theme.liquid before closing head tag </head>

Thanks 

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan

tim
Shopify Partner
3764 351 1384

This is an accepted solution.

Nope. These pages have different content, so canonical is not applicable here. Canonical is used for pages with identical content.

For example -- when product belongs to 5 collections there are 5 collection-aware URLs pointing to this product page and one collection-less link. But the product page is the same -- this is where you'd use canonical.

 

See https://www.semrush.com/blog/canonical-url-guide/ 

 

If your want to hide those pages from search bots, then yes, you can use robots.txt, or, alternatively, you can set a metafield on these page objects.

Check https://community.shopify.com/c/shopify-discussions/hide-a-product-from-seo-and-from-the-shopify-fro... -- it talks about products, but you can do the same with pages.

 

When metafield is set to 1, these pages

  • would not be included in your sitemap (modifying robots.txt would not do it and Google will complain about "page in index, but disallowed by robots"
  • would set <META NAME="robots" CONTENT="noindex,nofollow"> in the head of this page (kinda equivalent to disallow in robots.txt)
  • not shown by site own search

And no need to modify your theme.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
surfingcinv
Excursionist
39 1 12

Thanks. This looks like the right solution in this case. I pasted detailed instructions for anyone else trying to do this for shopify (PAGES)

  • Once logged into your Shopify admin
  • Select Settings.
  • Scroll down to Metafields on the side bar.
  • Select Pages and click on Add definition.
  • Enter a title for the metafield, I used “Hide from search engines” so it’s recognizable.
  • Replace the content in Namespace and key with seo.hidden – this must be exactly as you see it here.
  • Select the plus icon to Select content type and choose Number.
  • Make sure Integer is selected.
  • Select Save.

Shopify Admin dashboard, go to your pages and select the page you wish to hide from search engines.

Once on your product page, scroll to the very bottom.

You’ll now see the metafield you’ve added.

  • Select the text area in the gray box.
  • Enter 1.
  • Select Save.

The end result is that particular page will be removed from search engines. You can verify this by right clicking on the page and selecting View Source. Look for robots and you should see in the code that it now says:

<meta name="robots" content="noindex,nofollow" />