Canonical tag
Last reviewed
A canonical tag is a <link rel="canonical"> element that tells search engines which URL is the preferred version of a page when the same content is available at several URLs. Google treats it as a strong signal, not a command, and makes the final choice itself.
Syntax
In the HTML <head>:
<head>
<link rel="canonical" href="https://www.example.com/shoes/red-sneakers/">
</head>
As an HTTP header, for PDFs and other non-HTML files:
HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <https://www.example.com/downloads/white-paper.pdf>; rel="canonical"
Canonical signals and their strength
| Method | Strength (Google) | Use for |
|---|---|---|
| Redirect (301, 308) | Strong | Old or retired URLs |
rel="canonical" link element |
Strong | Duplicates that must stay reachable, such as tracking or filter parameters |
rel="canonical" HTTP header |
Strong | PDFs and other non-HTML files |
| Sitemap inclusion | Weak | Listing your preferred URLs |
Google says these methods stack and are more effective when combined. None of them is required. Without them, Google picks the canonical itself based on content similarity.
Self-referencing canonical
A self-referencing canonical points to the page's own URL. Google recommends including a rel="canonical" link on the canonical page itself. It keeps the preferred URL clear when the page is reached with parameters such as ?utm_source= or a different case or trailing slash.
<!-- On https://www.example.com/pricing/ -->
<link rel="canonical" href="https://www.example.com/pricing/">
Common mistakes
- Relative URLs. Google recommends absolute URLs. A relative
href="/pricing/"can point to the wrong host, for example when a test site gets crawled. - Canonical outside
<head>. Google only accepts the link element in the<head>section. - Several different canonicals on one page. Templates and plugins can each add one. Keep exactly one.
- Using robots.txt for canonicalization. Google says not to. A blocked page cannot pass its signals.
- Using noindex to choose a canonical. Google does not recommend
noindexfor picking a canonical within one site. - Canonical to a redirect, a 404 or a noindex page. Point it at a live, indexable URL that returns 200.
- Every page pointing to the home page. Canonical is for duplicates. Different pages should point to themselves.
- Mismatched signals. Canonical says one URL, internal links and the sitemap use another. Keep them consistent.
How to check your canonical
- View the raw HTML and find the tag:
curl -s https://www.<your-domain>/page/ | grep -io '<link[^>]*rel="canonical"[^>]*>'
- Check for an HTTP header version:
curl -sI https://www.<your-domain>/file.pdf | grep -i '^link:'
- In Google Search Console, the URL Inspection tool shows the user-declared canonical and the Google-selected canonical. If they differ, Google chose another URL.
On JavaScript sites
Google's guidance is to set the canonical in the HTML source. If JavaScript changes it to a different URL, Google sees conflicting signals. If you cannot set it in the HTML, Google says to leave it out of the HTML and set it only with JavaScript.
That fallback works for Google, which renders JavaScript. It does not work for crawlers that do not run JavaScript. The major AI crawlers, including GPTBot and ClaudeBot, only read the HTML your server sends, so a canonical set by a client-side router is invisible to them. Single page apps often ship one index.html for every route, with either no canonical or the home page canonical on every URL.
The fix is to have the correct canonical for each route in the HTML that crawlers receive: server-side rendering, static generation or prerendering.
See what ChatGPT sees on your site
FAQ
Is the canonical tag a directive?
No. Google calls rel="canonical" a strong signal. It can choose a different canonical if other signals disagree.
Should every page have a self-referencing canonical?
Google recommends adding a canonical link on the canonical page itself. It costs nothing and protects against parameter and casing duplicates.
Canonical tag or 301 redirect?
Use a redirect when the old URL should no longer be used. Use a canonical tag when both URLs must keep working, such as filtered or tracked URLs.
Can I use a relative URL in rel=canonical?
It is allowed, but Google recommends absolute URLs to avoid pointing to the wrong host.
Can a canonical point to another domain?
Yes. Cross-domain canonicals are supported, for example for syndicated content.