Canonical tags for vendor pages

Hiya, i’ve had an issue where i’ve seen that a vendor page has cannibalised a collection page and stolen its place in the SERP’s. I found the code below for canonical tags from shopify. I’m wondering if anyone knows the correct code to make vendor pages prioritise to collection pages if there is a collection with the same name as the vendor?

The url format we want to change is: https://www.site.com/collections/vendors?q=brandname

and to make it priotise towards: https://www.site.com/collections/collectionname

If anyone knows that would be a fantastic help! The code i’m referring to is below.

{{ page_title -}} {%- if current_tags %} – tagged "{{ current_tags | join: ', ' }}"{% endif -%} {%- if current_page != 1 %} – Page {{ current_page }}{% endif -%} {%- unless page_title contains shop.name %} – {{ shop.name }}{% endunless -%}

{% if page_description %}

{% endif %}

Hello @allymcc

To change the URL format from https://www.site.com/collections/vendors?q=brandname to https://www.site.com/collections/collectionname, you can modify the canonical_url variable in your code.

Assuming that the collectionname value is available in a variable called collection_name, you can update the code as follows:


{% if page_description %}

{% endif %}

Make sure to replace {{ collection_name }} with the actual variable or value that represents the desired collection name. This will generate the canonical_url with the updated format you mentioned: https://www.site.com/collections/collectionname.

Thank you so much! You’re a star :star:

Thank you for your response. It’s good to know that it’s worked for you. Kindly feel free to get back to me if you need any further assistance.
If helpful then please Like and Accept Solution.

For anyone else looking for the answer and doesn’t have the needed variables this is how I did it:

{% if collection.handle == 'vendors' %}
{%- assign collection_title = collection.title | downcase | replace: " ", "-" -%}

{% else %}

{% endif %}

Where shall we put this code?