Tag Page Change Canonical Tag

Highlighted
New Member
1 0 1

Hi,

For my store I have pages link that end link this: /blogs/recipes?page=2

Currently the canonical is self referencing, however I would like the canonical to be set as the base url so: /blogs/recipes

I modified my theme.liquid and it works for collection pages but Im not sure the code code for blog pages.

{% if template contains 'collection' %}
<link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}

 

Could someone please advise the correct code for this.

 

Thanks

 

Tom

 

 

1 Like
Highlighted

It could depends by the theme you are using but you can try this code:

    {% if template contains 'collection' %}
      <link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
    {% elsif template contains 'blog' %}
      <link rel="canonical" href="{{ shop.url }}{{ blog.url }}" />
    {% else %}
      <link rel="canonical" href="{{ canonical_url }}" />
    {% endif %}

 

• If the problem is solved remember to click ✅ to Accept Solution
• Press Like, if the answer was helpful
• Shopify/Shopify Plus custom development, optimization and consulting. You can hire me here.
1 Like