Skip to main content
Best Web Developer — web design, development and digital growth agency
Language and currency EN $ USD

Language

  • More languages coming soon

Currency

Prices on this site are shown in the currency you choose.

Documentation

rel=canonical: how canonical URLs work

How to tell search engines which of several duplicate URLs to index, with working HTML and HTTP header examples, the mistakes that break it, and how to verify it.

What a canonical URL is

The same content is often reachable at more than one URL: with and without a trailing slash, over HTTP and HTTPS, with tracking parameters, sorted or filtered, or printed. Search engines group these duplicates and choose one URL, the canonical, to show in results. The others are crawled less often and consolidate their signals into the canonical.

A rel="canonical" annotation is how you tell search engines which URL you prefer. Google treats it as a strong hint, not a command: it combines it with redirects, internal links, sitemaps, HTTPS and other signals, and can choose a different URL if your signals disagree.

Declaring the canonical in HTML

Put one link element in the head of every version, including the canonical page itself:

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

Use an absolute URL with the scheme and host. Relative URLs are allowed but are easy to get wrong, for example when a staging host or an HTTP version is served.

Declaring it in an HTTP header

For non-HTML files such as PDFs, send a Link header:

HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <https://www.example.com/guides/sizing.pdf>; rel="canonical"

On Apache this can be set with Header set Link inside a Files block. Use one method per URL: an HTML element and a header that disagree cancel each other out.

Self-referencing canonicals

Every indexable page should usually name itself as canonical. That protects it from parameter variants such as ?utm_source=newsletter or session IDs, which otherwise create duplicates you never linked to.

Cross-domain canonicals

When the same article is published on two of your sites, or syndicated with permission, the copy can point to the original on another domain:

<link rel="canonical" href="https://original-site.example/article/">

Google supports cross-domain canonicals, but for syndicated content it notes that the canonical may not always be honoured, and recommends that partners use noindex if you need the copy kept out of search.

Pagination, filters and variants

  • Paginated series. Page 2 of a category is not a duplicate of page 1, so each page should canonicalise to itself. Pointing every page at page 1 hides the products or posts on later pages.
  • Sorting and filtering. Parameters that only reorder the same items, such as ?sort=price, should canonicalise to the unparameterised URL. Filters that create genuinely different pages you want found can stand on their own.
  • Product variants. Colour or size variants with nearly identical content can canonicalise to the main product. Variants with distinct content, searches and stock can be indexed separately.
  • Mobile URLs. On sites with separate mobile URLs, the mobile page canonicalises to the desktop page, which carries a rel="alternate" link with a media query.
  • International versions. Each language version canonicalises to itself and lists the others with hreflang. Never canonicalise a translation to another language.

Common mistakes

  1. Several canonical elements on one page. Themes and SEO plugins sometimes both add one. When they conflict, Google ignores them.
  2. Canonical in the body. The element must be in the head. A canonical that ends up in the body, for example after an unclosed tag, is ignored.
  3. Pointing to a URL that redirects, returns 404 or is noindexed. The canonical should be the final, indexable, 200 response.
  4. Mixing canonical and noindex. Telling Google a page is a duplicate of another and also not to index it sends conflicting signals. Choose one.
  5. Changing the canonical with JavaScript. Google reads the canonical in the raw HTML and again after rendering. Different values conflict, so set it in the server HTML.
  6. Using robots.txt to hide duplicates. A blocked URL cannot be crawled, so Google never sees its canonical annotation.
  7. Internal links to non-canonical URLs. Links, sitemaps and redirects should all use the canonical URL so every signal agrees.

How to verify a canonical

  1. Fetch the page with the Fetch & Render tool and look at the canonical field. It reports canonicals from both the HTML and the Link header, and flags a canonical that changes after JavaScript runs.
  2. Fetch the canonical URL itself and confirm it returns 200, is not noindexed and names itself as canonical.
  3. Compare Googlebot and browser responses with the Pre-rendering Tester to make sure both get the same canonical.
  4. In Search Console, URL Inspection shows the canonical you declared and the canonical Google selected. If they differ, look for conflicting signals such as internal links or redirects.

Questions

Common questions

The things clients actually want to know — costs, timelines, ownership and what happens after launch.

No. Google treats it as a strong hint and weighs it with redirects, internal links, sitemaps and other signals. Consistent signals make it far more likely to be followed.

Every indexable page benefits from a self-referencing canonical, which protects it from parameter and tracking variants.

Use a redirect when the old URL should no longer be visited, such as after a migration. Use a canonical when both URLs need to keep working for people.

Yes. Google supports cross-domain canonicals, for example for content you publish on more than one of your sites.

Usually because other signals disagree: internal links, sitemaps or redirects point elsewhere, the declared canonical is not accessible, or the pages are not true duplicates.

Last reviewed: by the Best Web Developer engineering team.

Free strategy session

Let’s build something worth finding.

Tell us where you want the business to be in twelve months. We will come back with a costed plan, a realistic timeline, and the numbers we expect to move — no obligation, no jargon.

  • 30-minute call, no pitch deck
  • Fixed-price proposal in 48 hours
  • You own everything we build

Talk to a developer

Not a sales team

Response time
Within 1 business hour
Where we work
UK, USA & the Gulf
Contracts
No lock-in, monthly rolling
Working since
2023
infobestwebdeveloper.org

Free strategy session

Let’s build something worth finding.

Tell us where you want the business to be in twelve months. We will come back with a costed plan, a realistic timeline, and the numbers we expect to move — no obligation, no jargon.

  • 30-minute call, no pitch deck
  • Fixed-price proposal in 48 hours
  • You own everything we build

Talk to a developer

Not a sales team

Response time
Within 1 business hour
Where we work
UK, USA & the Gulf
Contracts
No lock-in, monthly rolling
Working since
2023
infobestwebdeveloper.org
Free consultation