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

Solved

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

AlexLaurin
Shopify Partner
10 0 3

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!

Accepted Solution (1)

AHAY
Shopify Partner
44 5 13

This is an accepted solution.

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:

<link rel="canonical" href="https://domain.com/products/product-handle">


I hope this helps

If you find my answer useful please do like/accept it so I feel more motivated to help in my spare time.

View solution in original post

Replies 3 (3)

AHAY
Shopify Partner
44 5 13

This is an accepted solution.

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:

<link rel="canonical" href="https://domain.com/products/product-handle">


I hope this helps

If you find my answer useful please do like/accept it so I feel more motivated to help in my spare time.
AlexLaurin
Shopify Partner
10 0 3

Good point!

 

The theme.liquid file's header contains this

  <link rel="canonical" href="{{ canonical_url }}">

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!

AHAY
Shopify Partner
44 5 13

Glad to be of help.

If you find my answer useful please do like/accept it so I feel more motivated to help in my spare time.