Changing canonical URL of products in collection

Highlighted
New Member
2 0 0

Hi all,

I would like some help with an issue that has been confusing me.

On my site the default URL for search engines is [ShopURL]/products/[product name].

The problem is when people click on this URL, the breadcrumbs on the product page only takes them back to the 'all products' page rather than the specific collections page, which I think is bad for user experience. It would be better if the standard URL for products was [ShopURL]/collections/[collection-URL]/product/[product-URL].

I know this is to do with the canonical tag, but the standard canonical tag in Shopify seems to just be to make the current page URL the canonical. Are there any edits people can suggest to the code below which I took from the theme.liquid template below to change the product canonical to always include the collection?

{% if template contains 'product' %}
  {% if product.metafields.seo.unique_url == blank %}
    <link rel="canonical" href="{{ canonical_url }}" />
  {% else %}
    <link rel="canonical" href="{{ product.metafields.seo.unique_url }}" />
  {% endif %}
  {% else %}
  <link rel="canonical" href="{{ canonical_url }}" />
  {% endif %}

Thanks in advance,

Matthew

0 Likes
Highlighted
Shopify Expert
9852 98 1619

There's a reason why the /product is the default - a product can exist in multple collections. By choosing that url, it removes any concerns of duplicate content. 

If you want to change it so the collection/product url is used what's your plan for defining what collection you set here. You have to pick one otherwise you'll run into duplicate content issues

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
New Member
2 0 0

Hi Jason,

Thanks for your reply and I see your point. However, the products on my website are only in one collection each so it wouldn't be too much of an issue, but I can see why Shopify have set it that way.

Thanks,

Matthew

0 Likes