Why is the collection handle included by default in products URL if it is bad for SEO?

Hi,

The product cards includes a line of code such as this one to determine its url structure:

data-product-url="{{ product.url | within: collection }}"

Depending, it generates urls as:

domain.com/collections/collection-handle-1/products/product-handle

domain.com/collections/collection-handle-2/products/product-handle

domain.com/products/product-handle

Since creating multiple urls for the same page, is bad for SEO, why is it set like this by default?

Thank you for enlightening me!

1 Like

Good catch thank you for sharing but I’m not sure where in reality the ‘domain.com/collections/collection-handle/products/product-handle’ can be accessed directly at all without manually entering the url !

Further, and I think more importantly, Shopify seems to use ‘canonical tags’ to indicate to search engines the preferred URL for a particular page. Inspect the source of any product page and you’d see the canonical tag implemented to specify the preferred URL for the product page as ‘domain.com/products/product-handle’ and not ‘domain.com/collections/collection-handle/products/product-handle

The link in the souce code would be something like:


I hope this helps

1 Like

Good point!

The theme.liquid file’s header contains this


I investigated the canonical_url and stumbled upon a guide from Shopify, here’s a good excerpt:

“In Shopify, the canonical_url object returns the canonical URL for the current page. The canonical URL is the page’s “default” URL with any URL parameters removed. It can be output like this: {{ canonical_url }}. For Shopify products and variants, the canonical URL output is the default product page with no collection or variant selected.”

In other words, it makes no sense to delete the collection reference in product’s URLs parameters since canonical tags tell search engine which URL is the preferred URL. The collection reference is also useful to understand visitor’s page paths.

Thanks for your help!

1 Like

Glad to be of help.