Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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!
Solved! Go to the solution
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
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
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!
Glad to be of help.
We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024