Adding Canonical Tags to Product Variant Pages

Using Canonical Tags for Product Variant Pages in Shopify and WooCommerce

Canonical tags help prevent duplicate content issues by specifying the “preferred” version of a web page. This is particularly useful for eCommerce sites with multiple product variants.


In Shopify, you can add canonical tags by editing your theme’s theme.liquid file. Follow these steps:

  1. Go to Online Store > Themes > Actions > Edit Code.
  2. Open the theme.liquid file.
  3. Add the following code within the section:
{% if template == 'product' %}
 <link rel="canonical" href="{{ product.url }}" />
{% endif %}

This code dynamically sets the canonical URL for each product variant page.


In WooCommerce, you can use a plugin like Yoast SEO to manage canonical tags. Follow these steps:

  1. Install and activate the Yoast SEO plugin.
  2. Go to SEO > Search Appearance > Content Types.
  3. Scroll down to Products and ensure the Show Products in search results? option is set to Yes.
  4. Yoast SEO will automatically add canonical tags to your product pages, including variants.

For more control, you can manually set canonical URLs in the Yoast SEO meta box on each product edit page.