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
- Several canonical elements on one page. Themes and SEO plugins sometimes both add one. When they conflict, Google ignores them.
- 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. - Pointing to a URL that redirects, returns 404 or is noindexed. The canonical should be the final, indexable, 200 response.
- Mixing canonical and noindex. Telling Google a page is a duplicate of another and also not to index it sends conflicting signals. Choose one.
- 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.
- Using robots.txt to hide duplicates. A blocked URL cannot be crawled, so Google never sees its canonical annotation.
- 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
- 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.
- Fetch the canonical URL itself and confirm it returns 200, is not noindexed and names itself as canonical.
- Compare Googlebot and browser responses with the Pre-rendering Tester to make sure both get the same canonical.
- 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.