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 %}
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.
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
Subject | Author | Posted |
---|---|---|
2 hours ago | ||
2 hours ago | ||
3 hours ago | ||
4 hours ago | ||
4 hours ago |