Product page canonical

Product page canonical

New Member
7 0 0

For the Product Variant pages to get actually indexed by Google, they need to get their own canonical.

Current status example:

has current canonical:
<link rel="canonical" href="" />

the correct Canonical should be a Canonical to self:
<link rel="canonical" href="" />

Exception: is the same page as:

The variant should keep his canonical to to prevent duplicate content.

All variant URLs are available to us and we can provide you with a list of ALL ?variant=xxxxxxxxx URLs of ALL product variants.
This also means we have all ?variant=xxxxxxxx exceptions


Can someone help us with this?

Replies 3 (3)

Shopify Staff
2873 312 819

Hi Martin,


Just to confirm - you'd like each individual version of a product page that contains the variant ID to be a unique canonical URL?


It should be possible to use liquid to set up logic and conditions that when a page is a product page, that the canonical URL has the variant ID appended to it. You could also create a list of exception urls so that the default behaviour keeps for those variants that need the canconical URL without the variant. An example of what this could look like might be something like:


{% assign exception_list = 'url1,url2,url3,url4,url5' | split: ',' %}
{% assign current_variant_url = shop.url | append: variant.url %}

{% if template contains 'product' %}
  {% if exception_list contains current_variant_url %}
    <link rel="canonical" href="{{ shop.url | append: product.url }}" />
  {% else %}
    <link rel="canonical" href="{{ current_variant_url }}" />
  {% endif %}

{% endif %}


In this case when a variant's URL is in the exception list array, it's URL will appear as just the regular shop URL but if it's not in the exception list it would be appended with the variant.url Liquid object. This code would be added where your themes canonical urls are being defined, likely in the theme.liquid file.


This is just a basic example of how this could be implemented, so you might need to adjust and test for your own purposes before deploying to any live themes - also it's worth keeping Googles own duplicate content best practices


Hope this helps, 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog

New Member
7 0 0

Hi Liam!

Thank you for your efforts to provide us with a solution.
When I implement the code you provide and add some exception URLs, the following happens:
- The exceptions work correctly has a canonical to:, which is correct

- the canonical to self does NOT seem to work: should have a canonical to self, but gets a canonical to our homepage ( <link rel="canonical" href="" /> ) Do you have any solutions for this?

We are well aware of duplicate content guidelines and all product variants have unique titles. Google is currently even ignoring some of the product page variant canonicals in favor of indexing these product variants (Canonicals are not directives for Google).

Kind regards,


1 0 0

Hello Martin,

Did you find a solution for your problem. I currently have the same issue. I appreciate if you can share the solution if you found it.

Kind Regards,