How to Change Canonical Tag of Collections/All Page?

New Member
2 0 1

Hopefully this is the right place for this question - I've got a setup where only 1 product exists. 

Because the product exists at the product URL without any issues, I don't really want the collections/all page to be indexed.

Is there a way to edit the canonical tag for the collections/all page (https://www.site.com/collections/all) so that it isn't self-referencing but instead points to my Product URL?

The collections page is indexed in Google / showing for some queries and I'd rather avoid this if I can.

Thanks for any help!


1 Like
Shopify Partner
49 9 20

Hey Matt,

 

The best option would be a URL redirect. Unfortunately, those only work for pages that would otherwise return a 404.

The approach I would recommend for you is to update your theme's header. There will be a section that emits the link rel=canonical tag. You can add a little bit of liquid logic to check the global canonical_url object to see if it is equal to /collections/all. If it is, emit the appropriate canonical URL for your product.

You may also want to emit the http-equiv=refresh meta tag, to hint to browsers to automatically redirect to the product page.

Hope that helps! Let me know if you have follow up questions. 

Code 402 Inc - Ecommerce Consulting in Kitchener, Ontario, Canada
1 Like
New Member
2 0 1

Thanks very much for this, Code402!

This seems a bit of a strange setup - to only be able to add a redirect if the page serves a 404. Do you know if my situation described is common - and whether it's worth making that change to the theme header? 

From my reports I can see the collections page I refer to is indexed in Google, and does get a small amount of search traffic - so from an SEO perspective it seems like the canonical edit is needed (with the redirect being impossible to add).

Thanks again!
Matt

0 Likes
Shopify Partner
49 9 20

Unfortunately, the limits of control over URL structure is a pretty popular complaint if you search for Shopify SEO stories. :(

Hopefully you'll find that it's worth it - the rest of the Shopify platform is pretty powerful.

Code 402 Inc - Ecommerce Consulting in Kitchener, Ontario, Canada
0 Likes