How to Canonicalize Filtered Collection URLs on Shopify to Improve On-page SEO

Eli Williams
1 min readNov 8, 2018

Something I’ve come across (part of a larger problem with Shopify filtering) that was affecting my organic traffic was users landing on filtered collection pages with a different URL than the main collection page itself (the one I want to rank).

For example, if you see users landing on www.yourstore.com/collections/hats/color_blue instead of www.yourstore.com/collections/hats because for some reason the color_blue filtered version of that collection ranks better on Google, this might help you point the traffic in the right direction. This will also set the canonical URL for paginated collections to the main collection.url for URLs with ?page=2 and beyond. It’s probably in some themes already, but it wasn’t in mine.

Ok, so how do I fix my liquid theme template?

In your theme.liquid file, simply replace

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

with

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

This should solve the problem for most. Also, according to what I've found Googling around, it is generally better to canonicalize your URLs instead of telling Google not to index them. If any SEO people want to weigh in please do.

If you liked this, follow me on Twitter @elitwilliams.

--

--