Shopify tags - Avoiding duplicate content

New Member
3 0 0

I used below code to prevent duplicate content. Everything works fine except ALL PRODUCT URL with tags(collections/all/red) are pointing to homepage as canonical. This solution has been taken from below URL

https://eastsideco.com/blog/shopify-product-tags-bad-for-seo

 

{% if template contains 'collection' and current_tags %} <meta name="robots" content="noindex" /> <link rel="canonical" href="{{ shop.url }}{{ collection.url }}" /> {% else %} <link rel="canonical" href="{{ canonical_url }}" /> {% endif %} 
0 Likes
Highlighted
Tourist
9 0 9

Hmmm...  Looks like `{{ collection.url }}` returns blank for the all products collection.  It should be `/collections/all`.  That's why you're getting just the main shop URL.  It's happening to me as well.  That's gotta be a bug in the Shopify system, I would think.  Theoretically, it shouldn't matter, since this code snippet is also adding a `noindex` tag as well.  That should mean that Google will ignore this page anyway.  I think.

 

Anyway, looks like there is a bug in the system.

0 Likes
New Member
3 0 0

May not be a bug in the system as shopify defines it as All products. This code works well if All products is converted to a Collection following instructions below.

 

https://help.shopify.com/en/themes/customization/collections/change-catalog-page

0 Likes
Tourist
9 0 9

For me, the `collections/all` collection uses the base `collection.liquid` template, and returns the title when using `{{ collection.title }}`.  That shows that it has a collection object, which naturally should have a URL.  Seems like a bug, or at least an illogical setup.

0 Likes