What Is a Canonical Tag and When to Use It on Your Website

If you have ever looked at your analytics or a crawl report and found the same page living at five different addresses, you already understand why the canonical tag exists. It is one of the smallest pieces of code on a website and one of the easiest to get wrong.

This guide keeps it simple. No jargon walls, no theory for the sake of theory. Just what a canonical tag is, where duplicate URLs actually come from, how to set one correctly in WordPress, Shopify and plain HTML, and the mistakes we see most often when auditing client sites.

What is a canonical tag?

A canonical tag is a line of HTML that tells search engines: this is the main version of this page, please rank and index this URL instead of the near-identical ones.

It looks like this and it lives in the <head> of your page:

<link rel="canonical" href="https://example.com/shoes/running-shoes/" />

Two things worth remembering right away:

  • All the duplicate URLs stay accessible to visitors. A canonical tag is not a redirect and it does not block anything.
  • The canonical tag is a hint, not an order. Google takes it as a strong signal, then makes its own decision. If your signals contradict each other, Google may pick a different URL as canonical.

Canonical URL vs canonical tag

The canonical URL is the address you want in search results. The canonical tag (also written rel="canonical") is the code that declares it. When search engines ignore your declaration, tools like Google Search Console will report a Google-selected canonical that differs from your user-declared canonical.

duplicate web pages

Why duplicate URLs happen (it is rarely your fault)

Almost nobody creates duplicate content on purpose. Duplicate URLs are usually generated automatically by the platform, the theme, or the marketing tools plugged into it. Here are the usual suspects.

Source of duplication Example URL Canonical should point to
Faceted navigation / filters /shoes/?color=black&size=42 /shoes/
Sorting and view options /shoes/?sort=price_asc&view=grid /shoes/
Tracking parameters (UTM, gclid, fbclid, affiliate IDs) /offer/?utm_source=newsletter /offer/
Print or AMP versions /article/print/ /article/
Syndicated or republished articles partner-site.com/our-article/ yoursite.com/our-article/ (cross-domain canonical)
Same product in several categories /collections/sale/products/lamp /products/lamp
Protocol, www, trailing slash, uppercase, index.html http://www.site.com/Page/index.html https://site.com/page/
Session IDs, internal search, replytocom, pagination artifacts /blog/post/?replytocom=812 /blog/post/

Left alone, these variants split your signals: links, engagement and crawl budget get spread across near-identical pages instead of consolidating on one strong URL.

duplicate web pages

When should you use a canonical tag?

Use a canonical tag when several URLs need to stay live but only one deserves to rank. Typical cases:

  1. Filtered, sorted or paginated variants of a category page that you do not want in the index.
  2. URLs with tracking or session parameters that campaigns keep generating.
  3. Product pages reachable through multiple category paths.
  4. Print-friendly, mobile-specific or PDF-adjacent versions of a page.
  5. Content you syndicate to partners, press portals or Medium (ask them to canonicalize to your original).
  6. Near-duplicate pages such as location or size variations with almost identical copy.
  7. Every normal page, as a self-referencing canonical (see below).

The self-referencing canonical

A page can point its canonical at itself. That is not redundant, it is good hygiene: it protects you when someone links to your page with a stray parameter, or when a scraper copies it. Most modern CMS platforms do this automatically.

When NOT to use a canonical tag

Situation Better tool
The old URL should disappear for users too 301 redirect
Thin, private or utility pages you never want indexed (cart, thank-you, internal search) noindex (used alone)
Same page in different languages or countries hreflang plus a self-referencing canonical on each version
Millions of crawlable filter combinations wasting crawl budget Canonical plus internal linking rules, sometimes robots.txt for extreme cases
Genuinely different pages targeting different needs Nothing. Keep them separate and differentiate the content

How to write a canonical tag correctly

The rules are short, so there is no excuse for breaking them:

  • Place it inside <head>, never in the <body>.
  • Use one canonical per page. Two conflicting tags means both get ignored.
  • Use an absolute URL with protocol and domain, not /page/.
  • Point to a URL that returns 200 OK, is indexable, and matches your sitemap and internal links.
  • Match case and trailing slash exactly with the live URL.

Raw HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Running Shoes</title>
  <link rel="canonical" href="https://example.com/shoes/running-shoes/" />
</head>

For non-HTML files such as PDFs, you cannot add a tag, so use the HTTP header instead:

Link: <https://example.com/whitepaper/>; rel="canonical"

WordPress

WordPress core already outputs a self-referencing canonical on single posts and pages. You usually only need to intervene for specific overrides.

  • Yoast SEO: edit the post, open the SEO panel, go to Advanced, and fill the Canonical URL field.
  • Rank Math: post editor, Advanced tab, Canonical URL.
  • All in One SEO: post settings, Advanced, Canonical URL.

For a custom template or an archive that needs a fixed canonical, add a small snippet in your child theme:

add_action( 'wp_head', function () {
    if ( is_page( 'print-version' ) ) {
        echo '<link rel="canonical" href="https://example.com/article/" />' . "\n";
        remove_action( 'wp_head', 'rel_canonical' );
    }
}, 1 );

WooCommerce note: filter and sorting parameters such as ?orderby=, ?filter_size= and ?min_price= should canonicalize to the clean category URL. Check a filtered page in view-source before assuming your plugin handles it.

Shopify

Shopify themes output a canonical automatically. Open layout/theme.liquid and look for this line inside the head:

<link rel="canonical" href="{{ canonical_url }}">

What that gives you out of the box:

  • /collections/sale/products/lamp canonicalizes to /products/lamp.
  • Tag-filtered collection URLs canonicalize to the parent collection.
  • Paginated pages get a self-referencing canonical on each page.

If you need a custom canonical for a specific template or metafield-driven page, override it conditionally rather than hardcoding one value site-wide:

{%- if template contains 'product' and product.metafields.seo.canonical != blank -%}
  <link rel="canonical" href="{{ product.metafields.seo.canonical }}">
{%- else -%}
  <link rel="canonical" href="{{ canonical_url }}">
{%- endif -%}

Beware of apps and third-party review or bundle tools that inject a second canonical tag. Two canonicals is worse than none. This discussion raises a few points we skipped.

duplicate web pages

7 canonical tag mistakes we keep finding in audits

1. Broken or missing self-referencing canonicals

Common versions of this bug: the canonical points to the staging domain, to http:// instead of https://, to the www version when the site runs without www, or to the URL without its trailing slash. Each one creates a mismatch and forces Google to guess.

2. Canonicals pointing to a redirected URL

If Page A canonicalizes to Page B and Page B 301s to Page C, you have created a canonical chain. Point directly at the final destination that returns 200 OK. The same applies to canonicals pointing at 404s, which are simply ignored. Originally covered on https://smartbugmedia.com.

3. Mixing canonical with noindex on the same page

These two send contradictory instructions: consolidate this page into another one and forget this page exists. Google may propagate the noindex to the canonical target. Pick one:

  • Want the signals consolidated? Use canonical only.
  • Want the page gone from search? Use noindex only, with a self-referencing canonical or none.

4. Canonicalizing everything to the homepage

A classic template error. Pointing every blog post or product at / tells Google those pages are duplicates of your homepage, and they drop out of the index. Much the same conclusion turns up on nextjs.org.

5. Multiple or misplaced tags

Two plugins, a theme and an app each adding their own tag equals conflicting signals. A canonical injected by JavaScript into the body, or after the head closes, does not count either. Always verify the rendered HTML.

6. Canonical targets blocked in robots.txt

If the target URL is disallowed, crawlers cannot confirm it, so the tag is wasted. Never combine canonicalization with a robots.txt block on the destination.

7. Contradicting yourself elsewhere

Your canonical says A, your sitemap lists B, your internal links point to C, and hreflang references D. Consistency is what makes a canonical stick. Signals must all agree.

duplicate web pages

How to check your canonical tags

  1. View source: open the page, search the source for rel="canonical". One result only.
  2. URL Inspection in Google Search Console: compare User-declared canonical with Google-selected canonical. A difference means your signals are not convincing.
  3. Pages report in Search Console: watch for Duplicate, Google chose different canonical than user and Alternate page with proper canonical tag.
  4. Crawler: Screaming Frog, Sitebulb or Semrush Site Audit will list canonical chains, loops, missing and non-indexable canonicals in bulk.
  5. Command line: curl -sL https://example.com/page/ | grep canonical for a fast sanity check.

Quick pre-launch checklist

  • Every indexable page has exactly one canonical, in the head, absolute URL.
  • Canonical targets return 200 and are not noindexed or blocked.
  • Parameter URLs (filters, UTM, sorting) canonicalize to their clean version.
  • No page canonicalizes to the homepage unless it truly is the homepage.
  • Sitemap contains only canonical URLs.
  • Syndication partners point their canonical back to your original article.

FAQ

What is a canonical example?

A product page reachable at https://shop.com/products/lamp and at https://shop.com/collections/sale/products/lamp. Both include this tag:

<link rel="canonical" href="https://shop.com/products/lamp" />

Search engines then index and rank the first URL, and the ranking signals from both are consolidated onto it.

What is a canonical URL example?

If your category page exists as /shoes/, /shoes/?sort=price and /shoes/?utm_source=facebook, the canonical URL is https://example.com/shoes/. That is the clean, parameter-free version you want people to land on from search.

Do canonical tags affect SEO?

Yes, indirectly but significantly. They consolidate duplicate signals onto one URL, stop near-identical pages from competing with each other, keep the right page in search results, and help crawlers spend their time on pages that matter. They are not a ranking factor on their own, but bad canonicals can absolutely remove pages from the index.

How to write a canonical tag?

Add a single <link rel="canonical" href="..." /> element inside the <head>, using the full absolute URL of the preferred version, ending with a URL that returns 200 OK. For files that are not HTML, send the equivalent Link HTTP header instead.

Is a canonical tag the same as a 301 redirect?

No. A redirect sends both users and crawlers to another URL, so the original stops being reachable. A canonical keeps every version usable for visitors and only expresses a preference to search engines. Use a redirect when the duplicate has no reason to exist, and a canonical when it does.

Can a canonical tag point to another domain?

Yes. Cross-domain canonicals are the standard fix for syndicated content: the partner publishing your article adds a canonical pointing to your original URL, so your version stays the one that ranks.

Should paginated pages canonicalize to page 1?

Generally no. Page 2 shows different items, so it is not a duplicate. Give each paginated page a self-referencing canonical and let search engines handle the series.

Need a second pair of eyes?

Canonical issues are cheap to fix and expensive to ignore, especially on ecommerce catalogs and content-heavy sites where a single template bug can affect thousands of URLs. If you would like us to audit your canonical setup, your parameter handling and your indexation coverage, get in touch with the PixelBright team and we will take a look.

Leave a Comment