All things Shopify and commerce
Right now, if I filter a collection page:
/collections/product-series?filter.p.product_type=Product+X
It canonicals back to:
/collections/product-series
What if I want to make the filtered results into an organic landing page so that it self-canonicals? Is that possible? I don't want to do it for all facet/filters but I would like to do it for some of them.
Thanks!
Yes, it is possible to set canonical URLs for filtered collection pages in Shopify. Here's how you can do it:
Identify the URL structure for your filtered collection pages: In your example, the URL for the filtered collection page is: /collections/product-series?filter.p.product_type=Product+X
. You'll need to identify the URL structure for your filtered collection pages so you can set the canonical URL correctly.
Add the following code to the head
section of your theme.liquid file:
{% if template == 'collection' and collection.handle == 'product-series' and current_query contains 'filter' %} <link rel="canonical" href="{{ collection.url }}{{ current_query }}"> {% endif %}
This code checks if the current page is a collection page with the handle "product-series" and if it contains a filter query string. If both conditions are met, it sets the canonical URL to the current collection URL with the query string included.
current_query
variable to match the query string parameter used in your URL structure.By adding this code to your theme.liquid file, your filtered collection pages will self-canonicalize based on the URL structure you've defined. This will help ensure that search engines understand which page is the canonical version, which can help improve SEO for your store.
Hi there,
I am not sure what do to with your response which looks by the way super accurate. : D
Basically, I have many filtered pages like:
> /collections/cbd-pour-animaux/dosages-legers
> /collections/cbd-pour-animaux/dosages-intenses
> /collections/cbd-pour-animaux/poids-1-a-5-kg
And I want all the above pages to be canonised pointing at page (to avoid duplicate content) :
/collections/cbd-pour-animaux
Based on that, can you tell me what code I need to put on the head section of your theme.liquid file ?
Thanks you
Yann
I am looking for a solution for the exact same issue
I think, product tag can help you like
If you have some products with tag tag-a then this /collections/your-collection/tag-a will show all these products and it has its own canonical url
Then you can create a navigation of such links and then call it.
Please check if it helps!
Thanks!
Hi there,
I am not sure what do to with your response.
Basically, I have many filtered pages like:
> /collections/cbd-pour-animaux/dosages-legers
> /collections/cbd-pour-animaux/dosages-intenses
> /collections/cbd-pour-animaux/poids-1-a-5-kg
And I want all the above pages to be canonised pointing at page (to avoid duplicate content) :
/collections/cbd-pour-animaux
Based on that, can you tell me what code I need to put on the head section of your theme.liquid file ?
Thanks you
Yann
User | RANK |
---|---|
40 | |
37 | |
24 | |
22 | |
15 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023