Shopify Canonical URL: What canonical_url Returns

A Shopify canonical URL comes from one Liquid object, canonical_url, which the theme prints in layout/theme.liquid. It drops the collection prefix from product URLs and every variant, sort, filter and utm_source parameter we tried, but keeps ?page= on paginated listings and ?q= on search and vendor pages. Most stores should leave the tag alone and fix the links that point at duplicates.

The reference page for canonical_url is one sentence long: “The canonical URL for the current page.” It does not say what that URL is for a filtered collection or a second page. So on 26 November 2026 we requested 31 URL shapes from Shopify’s public Dawn demo store, theme-dawn-demo.myshopify.com, and read the tag each one came back with.

What does canonical_url return for each kind of page?

Every value was an absolute URL on the store’s own domain. The table shows the paths.

RequestedCanonical
/products/otti-combat-boot?variant=39577002770521/products/otti-combat-boot
/collections/boots/products/otti-combat-boot/products/otti-combat-boot
/products/Otti-Combat-Boot/products/otti-combat-boot
/collections/bags?sort_by=price-ascending/collections/bags
/collections/bags?filter.v.availability=1/collections/bags
/collections/bags?page=1/collections/bags
/collections/bags?page=2/collections/bags?page=2
/collections/bags?filter.v.availability=1&page=2/collections/bags?page=2
/collections/vendors?q=Mlouye/collections/vendors?q=mlouye
/search?q=boot&page=2/search?page=2&q=boot
/no-such-page (a 404)/404

A trailing slash, ?view=list and ?utm_source=newsletter were all dropped as well. The search pages also came back with an X-Robots-Tag: noindex, nofollow header.

A Shopify Partners post from September 2021 describes the canonical as the page’s default URL “with any URL parameters removed”. That held for variant, sort_by, filter, view and utm_source. It did not hold for page, or for q on search, vendor and product type listings, which survived: lower-cased on the vendor and type listings, reordered on search.

Three kinds of URL are missing from the table. The store answered 429 every time we asked for a tag-filtered URL such as /collections/shoes/boots, and later served a bot challenge, at which point we stopped. So we have no reading for tag URLs, for Markets subfolders like /en-fr/, or for blog pagination.

Should page 2 of a collection point at page 1?

No, and Shopify does not do it. ?page=2 is its own canonical and ?page=1 collapses to the bare collection URL. That matches Google’s pagination guidance, which says: “Don’t use the first page of a paginated sequence as the canonical page.” Page 2 lists different products from page 1, so it is not a duplicate of it. If you inherit a theme customisation that strips the query string from canonical_url on collections, remove it.

The object does echo whatever page value it receives. ?page=0 and ?page=abc both rendered page 1 with a canonical that kept the junk value. ?page=999 on a two-page collection returned 200, a title containing “Page 999” and a canonical pointing at itself. None of that matters until something links to those URLs. A collection that shrinks is one way it happens: on this evidence, an old link to a page past the new last one still gets a 200.

The demo store’s collection pages also carried <link rel="prev"> and <link rel="next"> tags, which we could not find anywhere in the Dawn 16.2.0 source. Google’s page says it “no longer uses these tags”, so there is nothing to tune there.

What happens to sorted and filtered collection URLs?

They canonicalise to the unfiltered collection. ?sort_by=price-ascending and ?filter.v.availability=1 both pointed at /collections/bags.

The filter is dropped even when page is kept. A filtered second page pointed at /collections/bags?page=2, the unfiltered second page, which holds different products. We have no evidence of how Google treats that mismatch.

Google’s pagination page says to keep filter and sort variations out of the index with a noindex robots meta tag or a robots.txt rule. Shopify’s default robots.txt already disallows sorted collection URLs, and that has a side effect covered in our guide to editing Shopify’s robots.txt: a crawler that is not allowed to fetch a page never reads the canonical on it. We leave sorted and filtered URLs as they are, because the tag already names the unfiltered listing.

Where do duplicate product URLs come from?

From links in the theme. Shopify serves a product at /products/<handle> and again under a collection it belongs to: /collections/boots/products/otti-combat-boot returned 200 with a canonical pointing at the short URL. The one exception we saw was /collections/all/products/otti-combat-boot, which answered with a 301 to the short URL.

A crawler only finds the long form if your theme links to it, and the within filter is how themes do that. Its reference page carries a caution: “Because a standard product page and a product page in the context of a collection have the same content on separate URLs, you should consider the SEO implications of using the within filter.”

Dawn 16.2.0 does not use it. Its product cards link to card_product.url. Search your own theme for within: collection, because Google’s canonicalisation guide asks for the same thing: “When linking within your site, link to the canonical URL rather than a duplicate URL.” The filter’s reference page says the collection context is what gives the product template its collection object, so check for breadcrumbs or back links that depend on it before you remove the filter.

Variant URLs need no work. ?variant= was dropped on the short URL and on the collection-prefixed one.

How do you check a Shopify canonical URL on your own store?

Request one URL of each shape and read the tag. This script prints the status, the path and a verdict for each: self, the canonical it found, a redirect target, or a warning when the page has no canonical tag or more than one. The readings above came from a longer draft of it that also logged titles and headers. This version ran against a local mock server on Node 24.12.0 and needs nothing beyond the built-in fetch.

// Usage: node canonical-shapes.mjs https://your-store.example /products/a "/collections/b?page=2"
const [origin, ...paths] = process.argv.slice(2);
if (!origin || paths.length === 0) {
  console.error('Usage: node canonical-shapes.mjs <origin> <path> [<path> ...]');
  process.exit(1);
}

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const pause = Number(process.env.PAUSE_MS ?? 5000);

for (const path of paths) {
  const url = new URL(path, origin).href;
  const res = await fetch(url, { redirect: 'manual' });

  if (res.status === 429) {
    console.error(`429 on ${path}. Stop here, wait, then raise PAUSE_MS.`);
    process.exit(2);
  }

  let verdict;
  if (res.status >= 300 && res.status < 400) {
    verdict = `redirects to ${res.headers.get('location')}`;
  } else {
    const html = await res.text();
    const tags = html.match(/<link[^>]*rel="canonical"[^>]*>/gi) ?? [];
    const hrefs = tags.map((tag) => tag.match(/href="([^"]*)"/i)?.[1]);
    const noindex =
      /<meta[^>]*name="robots"[^>]*noindex/i.test(html) ||
      /noindex/i.test(res.headers.get('x-robots-tag') ?? '');

    if (hrefs.length === 0) verdict = 'no canonical tag';
    else if (hrefs.length > 1) verdict = `${hrefs.length} canonical tags: ${hrefs.join(', ')}`;
    else if (hrefs[0] === url) verdict = 'self';
    else verdict = hrefs[0];
    if (noindex) verdict += ' (noindex)';
  }

  console.log([res.status, path, verdict].join('\t'));
  await sleep(pause);
}

Quote any path that contains a ?, and include the shapes we could not read: a tag URL, a locale subfolder and a second blog page. Two canonical tags on one page mean something other than the layout is printing one as well. Find it and keep one.

Keep the pause. The demo store answered 429 to requests sent back to back, and again partway through a run spaced 4.5 seconds apart, which is why the script stops at the first 429 and does not retry.

When should you override the canonical tag?

Rarely, and almost never by changing the href. The cases worth acting on are listings Shopify generates that nobody curated: tag-filtered collections and blogs, and the vendor and product type listings at /collections/vendors?q= and /collections/types?q=, which canonicalised to themselves in our run. (Tag URLs we could not read, so check yours first.) If those are not pages you want in search, keep canonical_url and print a noindex beside it in layout/theme.liquid:

{%- liquid
  assign listing_noindex = false
  if current_tags
    assign listing_noindex = true
  elsif request.page_type == 'collection'
    if collection.current_vendor or collection.current_type
      assign listing_noindex = true
    endif
  endif
-%}
<link rel="canonical" href="{{ canonical_url }}">
{%- if listing_noindex %}
  <meta name="robots" content="noindex">
{%- endif %}

current_tags is set on tag-filtered collection and blog pages, and Shopify’s own SEO metadata example tests it the same way in the layout. current_vendor and current_type are documented on the collection object. We rendered this snippet with the open-source Liquid gem, version 5.14.0, against stubbed objects. We have not run it on a live store.

If a tag page is one you do want in search, leave it out of the condition. Better still, give those products a collection of their own, with a title and description you control.

One caution if you ever do change the href. Dawn’s snippets/meta-tags.liquid builds og:url from canonical_url, so a hand-written canonical and the Open Graph URL will disagree unless you change both.

Our recommendation: leave canonical_url as the only thing in the tag, ?page= included, and take within: collection out of product links. Add the noindex only for tag, vendor and type listings you never meant to publish. Re-run the script after each theme update or app install, since either can change what ends up in the <head>, and after a replatform run it alongside the redirect checker in our Shopify migration SEO checklist.

We build and audit Shopify themes, canonical tags and crawl paths included, as part of our Shopify development work.

Need this built properly?

Get in touch

Hack the planet!