Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hi,
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.
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.