How can I change the canonical tags on my website pages

New Member
2 0 0

Thanks @Jason  - it's a relieve we have some control over this.

 

Can you please elaborate on what meta tag is to be used and where it goes?

 

I can get rid of the theme's canonical tag, but what is the proper syntax of the custom meta canonical tag and where do I put it? Do I use the code view of the shopify product description field or is there some if/else trick like in @Lars6' example- where do I put this code?

 

funny - the liquid code he used in his post came through in my email but doesn't show here in the forum - I'll see if it works this time here:

 

{% if product.collections[1].handle contains "sale" or product.collections[1].handle contains "top" or product.collections[1].handle contains "all" %}

<link rel="canonical" href="{{shop.url}}/collections/{{ product.collections[2].handle}}{{product.url}}" />

{% else %}

<link rel="canonical" href="{{shop.url}}/collections/{{ product.collections[1].handle}}{{product.url}}" />

{% endif %}

{% elsif product.collections[0].handle != blank %}

<link rel="canonical" href="{{shop.url}}/collections/{{ product.collections[0].handle}}{{product.url}}" />

{% else %}

<link rel="canonical" href="{{canonical_url}}">

{% endif %}

{% endif %}
0 Likes
Shopify Partner
5 0 1
Yes I removed some the the lines because it will obviously look different in your theme. As you can see I added some „exceptions“ where some categories shouldn’t be used - e.g. „sale“. 
You need to add the code in the theme.liquid file. 
I am on my computer this evening - if there is still support needed I will copy - Paste this properly in this conversation. 
Best regards Lars 
0 Likes