The canonical tag: what it does and how to use it
·4 min read
A canonical tag is a <link rel="canonical"> element in a page's <head> that names the URL you want search engines to index when several URLs show the same content. Google treats the canonical tag as a strong hint, not a command, so it usually follows it but can pick another URL when your other signals disagree. Use one absolute URL per page, point it at a live, indexable page, and give each page you want ranked a canonical that points at itself.
What does a canonical tag do?
A canonical tag consolidates duplicates. When /shoes/, /shoes/?sort=price-asc and /shoes/?gclid=abc123 all show the same list, the tag tells Google to index /shoes/ and credit the variants' signals to it.
Google's canonicalization guide ranks the methods by strength. A redirect and rel=canonical are both strong signals. A sitemap listing is a weak one. None of them is a directive, which is why Search Console has a status for "Google chose different canonical than user". If your internal links and sitemap point at one URL and your canonical at another, Google may pick the first.
The guide also says none of these methods is required. I still add one to every page, because it costs one line of template code.
How to add a canonical URL: HTML tag or HTTP header
Put the tag in the <head> of the HTML.
<link rel="canonical" href="https://www.example.com/shoes/" />Files such as PDFs have no <head>, so send the canonical in an HTTP Link header instead. Google supports the header for web search results only.
Link: <https://www.example.com/downloads/size-chart.pdf>; rel="canonical"Four rules cover most setups:
- Absolute URLs. Google recommends them for both the tag and the header. A value like
example.com/shoes/without the scheme reads as a relative path, and Google may ignore it. - Inside
<head>. Google accepts the tag only there. An<img>or<div>printed early closes the head, pushing a later canonical into<body>, where Google disregards it. - One canonical per page. A 2013 Search Central post on common rel=canonical mistakes says Google will likely ignore every canonical when a page declares more than one. A plugin and a theme both adding one is the usual cause.
- Header and tag agree. If you send both, name the same URL. Google warns against giving one page different canonicals through different methods.
Should you use a self referencing canonical?
Yes. A self-referencing canonical is a tag on the preferred page that points at that page's own URL, and Google's guide tells you to include one on the canonical page.
It matters even on pages with no obvious duplicates. Ad platforms and newsletters append ?utm_source= or ?gclid= to your URLs without asking, and a self-referencing canonical in the template points every such variant back to the clean URL.
Match the URL you serve exactly, including https, host and trailing slash. A self-canonical of http://example.com/shoes on https://www.example.com/shoes/ points at a different URL.
Cross-domain canonical tags
A canonical can point at another domain. Google announced support for cross-domain rel=canonical in 2009 and called it a hint it tries to follow where possible.
The common use is syndication. If a partner republishes your article, ask them to put a canonical on their copy pointing at your original. Because it is a hint, the copy has to match the original closely. A rewritten version with a canonical to you is a signal Google may reject.
Common rel canonical mistakes
Most canonical bugs live in templates, so one bad line repeats across thousands of URLs.
| Mistake | What goes wrong | Fix |
|---|---|---|
| Canonical points at a redirect | Mixed signal, Google may pick its own URL | Point at the final URL that returns 200 |
| Canonical points at a 404 or 410 | The target is not a page Google can index | Point at a live URL |
| Canonical points at a noindex page | One URL says "index that", the other says "don't index me" | Remove noindex from the target or change the canonical |
| Every page points its canonical at the home page | Pages that are not duplicates claim to be | Self-referencing canonical on each page |
| Page 2 and later canonical to page 1 | Products or posts on later pages lose their path to the index | Give each page in the series its own canonical |
| Canonical set only by JavaScript | Crawlers that read raw HTML never see it | Put the tag in the server HTML |
Pagination gets its own line in Google's pagination guide, which says not to use the first page of a series as the canonical and to give each page its own.
Google's JavaScript SEO basics says it reads an injected canonical when it renders the page, but recommends HTML. A script must never change the canonical the HTML already set.
Google also says not to canonicalize with robots.txt or noindex, since noindex blocks the page from Search entirely.
For the Search Console statuses, read duplicate without user-selected canonical and alternate page with proper canonical tag. To confirm the result, see how to check if a page is indexed.
Check a page's canonical tag and its target
Our Indexing & Canonical Checker reads the canonical a URL declares in its HTML and in its Link header. It reports whether the canonical is self-referencing, points at another URL or is missing, and flags several canonicals, a tag outside <head>, a non-http(s) value and a header that disagrees with the tag. It then fetches the target and flags one that redirects, returns an error, carries noindex, or forms a chain or loop. The same run checks status, robots.txt, meta robots and X-Robots-Tag. A run costs 8 credits.
It does not render JavaScript, so a script-only canonical shows as missing, and it cannot tell you which canonical Google chose. URL Inspection in Search Console does that.