How to choose the canonical tag for the collection page

Topic summary

A website manager sought help with canonical tag implementation for paginated collection pages. The issue: paginated URLs (e.g., page=2, page=3) were self-canonicalizing instead of pointing to the main collection URL without parameters.

Solution Provided:
Modify the theme.liquid file by replacing the canonical link code:

  • Original: <link rel="canonical" href="{{ canonical_url }}">
  • Updated: <link rel="canonical" href="{{ canonical_url | split: '?' | first}}">

This strips query parameters from all canonical URLs, resolving pagination issues across collections and blogs.

Complications Identified:

  • The solution successfully fixed pagination canonicalization
  • However, it inadvertently affected vendor collection pages, causing them to lose proper canonicalization (vendor query parameters were stripped)

Refined Solution:
A conditional approach was suggested to apply the fix only to collection template pages, preserving correct canonicalization for other page types while solving the original pagination issue.

Status: The original poster confirmed the initial solution worked, though the vendor page complication suggests further refinement may be needed for some implementations.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

Hello dear Shopify community,

I am Henry, the manager of the website wrapsify.com. Currently, I am facing an issue related to the collection pages of the website.

Specifically, the collection pages on the website are currently paginated as 1, 2, 3, 4, 5,… and are not properly canonicalized to the original URL. For example, the URL https://wrapsify.com/collections/motorcycle-gifts?page=2 is currently canonicalized to itself: https://wrapsify.com/collections/motorcycle-gifts?page=2.

However, I want all pages 1, 2, 3, 4, 5,… of this collection to be canonicalized to the original URL: https://wrapsify.com/collections/motorcycle-gifts.

I have tried some solutions but have not found an effective way to solve this issue. I sincerely hope to receive support from you in the Shopify community to help me overcome this problem.

Thank you very much,

Henry from wrapsify.com

Hi @wrapsify

Just update the theme liquid file

Find

Replace with

It will fix all the pagination issues with blogs as well.

Steps to find the theme.liquid

  • Go to “Online Store” and then click on “Themes.”
  • Find the theme you want to edit and click on “Actions” > “Edit code.”
  • Locate theme.liquid:
  • In the left sidebar, you’ll see a list of files. Look for “theme.liquid” and click on it.
4 Likes

I did it successfully, thank you very much

If I managed to help you then, don’t forget to Like it and Mark it as Solution! 

Your Coffee Tip can create magic in coding

Will this also canonicalize the Collection and Blog tag pages as well?

1 Like

This worked for us too, thanks. However, I found that this also caused our vendor URLs to lose the correct canonicalization. For example:

https://www.website.com/collections/vendors?q=brandx gets the canonical https://www.website.com/collections/vendors

maybe try this to only apply it to collection pages:

{% if template == ‘collection’ %}
{%- assign new_canonical_url = canonical_url | split: ‘?’ | first -%}
{% else %}
{%- assign new_canonical_url = canonical_url -%}
{% endif %}