The same page is often reachable at many URLs: with and without www, with tracking parameters, with sorting options, through a print view or a category path. Search engines see these as duplicates, and pick one to show. A canonical URL tells them which version you prefer, so ranking signals consolidate on that URL instead of being split.
How it works
Add a link element to the <head> of every version of the page:
<link rel="canonical" href="https://example.com/blog/install-nginx-ubuntu/">
It’s a strong hint, not a command. Google usually follows it, but may choose differently if other signals contradict it (redirects, internal links, sitemaps pointing elsewhere). Search Console’s URL Inspection shows both the “user-declared canonical” and the “Google-selected canonical”.
Self-referencing canonicals
Every indexable page should point to itself:
<!-- on https://example.com/pricing/ -->
<link rel="canonical" href="https://example.com/pricing/">
Then, when someone links to https://example.com/pricing/?utm_source=newsletter, the canonical still says which URL counts. Most CMSs and SEO plugins do this automatically. In frameworks, build it from the site URL plus the path, without the query string.
Typical duplicate sources
| Duplicate | Best fix |
|---|---|
| http vs https, www vs non-www | 301 redirect + canonical. See redirect www to non-www |
| Trailing slash vs none | 301 to one style + canonical |
Tracking parameters (utm_*, fbclid) |
Canonical to the clean URL |
| Sort and filter parameters | Canonical to the main listing (or let important filters be indexable) |
Product in several categories (/shoes/x, /sale/x) |
Canonical to one primary URL |
| Syndicated copies on other sites | Cross-domain canonical to the original (if the partner agrees) |
| Print or AMP versions | Canonical to the main page |
Rule of thumb: if users never need the duplicate URL, redirect it. If the duplicate must exist (parameters, alternative paths), use a canonical.
Canonical vs redirect vs noindex
| Tool | Users see | Search engines | Use when |
|---|---|---|---|
| 301 redirect | The target page | Transfer signals; drop the old URL | Old URL has no reason to exist. See 301 vs 302 redirects |
| Canonical | The duplicate page | Consolidate signals to the canonical | Duplicate must stay accessible |
| noindex | The page | Drop the page from the index; no consolidation | Page shouldn’t be in search at all |
Don’t combine noindex and a canonical pointing elsewhere on the same page: they send conflicting signals.
Canonical for non-HTML files
For PDFs and other files, send it as an HTTP header:
location = /downloads/price-sheet.pdf {
add_header Link '<https://example.com/pricing/>; rel="canonical"';
}
Pagination
Page 2, 3… of a listing should canonicalize to themselves, not to page 1. Otherwise Google may ignore the items on later pages. (Google no longer uses rel="next"/"prev".)
Multilingual sites
Each language version is canonical to itself, and the versions link to each other with hreflang. Canonicalizing all languages to English hides the translations. See the hreflang guide.
Consistency matters
Google weighs all signals together. Make them agree:
- canonical tags;
- internal links (link to the canonical version, not parameter URLs);
- XML sitemap (canonical URLs only). See XML sitemaps;
- redirects;
- hreflang annotations.
Common mistakes
- Every page canonicalized to the home page (a template bug). Pages drop out of the index.
- Relative canonicals (
href="/page") that break on other hosts. Use absolute URLs. - Canonical pointing to a redirect, 404 or noindex page.
- Multiple canonical tags on one page (theme plus plugin). Google may ignore both.
- Canonical in the
<body>, or injected late by JavaScript. Put it in the server-rendered<head>. - Staging host in the canonical after launch (
https://staging.example.com/…). - Canonical to the HTTP version after moving to HTTPS.
Checking
curl -s https://example.com/pricing/?utm_source=x | grep -i 'rel="canonical"'
Crawlers such as Screaming Frog report missing, multiple, and non-self canonicals across the whole site. Search Console’s Pages report lists “Duplicate without user-selected canonical” and “Google chose different canonical than user”.
Quick reference
| Situation | Action |
|---|---|
| Every indexable page | Self-referencing absolute canonical |
| Duplicate users don’t need | 301 redirect |
| Parameter variants | Canonical to the clean URL |
| Paginated pages | Canonical to themselves |
| Language versions | Self canonical + hreflang |
| PDFs | Link header |
Related: technical SEO on your own server and SEO-friendly URLs.