Product page canonical

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

Current status example:
URL:
https://www.uipkesvloeren.nl/products/visgraat-vloer-helder-wit?variant=44508560425224

has current canonical:

the correct Canonical should be a Canonical to self:

Exception:

https://www.uipkesvloeren.nl/products/visgraat-vloer-koraal-wit?variant=44508559343880 is the same page as:
https://www.uipkesvloeren.nl/products/visgraat-vloer-koraal-wit

The variant https://www.uipkesvloeren.nl/products/visgraat-vloer-koraal-wit?variant=44508559343880 should keep his canonical to https://www.uipkesvloeren.nl/products/visgraat-vloer-koraal-wit 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?

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 %}
    
  {% else %}
    
  {% 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,

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:

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,

Martin

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,

Yamen