Controlling canonical tags manually

JarkkoPod
New Member
2 0 0

I have a couple of dozen collections that I would like to point to created pages using a canonical tag. These pages are basically more designed, advanced versions of these collections. I tried 301 redirecting the collections to the pages, but Shopify doesn't allow these collection pages to be redirected because they are working, existing pages. Only 404 pages can be redirected. So that's why I'm now trying to canonicalise them.

I cannot see where to set canonical URL's in the CMS, so do I need to hardcode them in the theme.liquid with a bunch of if statements? I believe it would look something like this?

 

{% if  collection.url contains 'shirts/t-shirts' %}

   <link rel="canonical" href="(domain name here)/pages/my-t-shirt-page ">

{% elsif  collection.url contains 'shoes/running-shoes' %}

    <link rel="canonical" href="(domain name here)/pages/my-running-shoes-page ">

{% else %}

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

{% endif %}

 

Is there an easier way? My worry is that this method is going to affect the load times on all pages.

I only want to canonicalise some of my collections in this way, so I need to be able to pick and choose which ones are affected.

0 Likes