FROM CACHE - en_header

Setting Product page canonical to point to the product's collection

New Member
1 0 0



I've found a few posts on canonical tweaks, but nothing that will let me do this.

I want to set all my products canonicals, to point to the collection that the product itself is assigned to (assuming only one assignment exists),


Can anyone show me how to do this please?


Many thanks.

Reply 1 (1)
Shopify Expert
861 33 220

Open the following file theme.liquid in the folder Layout

Find the following text:
<link rel="canonical" href="{{ canonical_url }}" />

And replace it with:
{% if template contains 'product' %}
<link rel="canonical" href="{{ product.url }}" />
{% else%}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}

This hasn't been tested. Update other links on your website to point to the collections version of the URL.

Run Google Shopping ads? Get the free definitive guide to Google Shopping for Shopify (no optin required):