SEO
What a canonical tag actually does
It is a request, not a rule: “if you are going to index this page, index that one instead.” Most of the trouble comes from treating it as a redirect.
Audit canonicals and hreflangYou have one article reachable at four URLs: with a tracking parameter, with a trailing slash, on thewww host, and on the staging domain that someone forgot to lock. Four pages, one article. A canonical tag is how you say which of the four is the real one.
The syntax, and the two mistakes
In the head of every duplicate: <link rel="canonical" href="https://example.com/article">. Absolute URL, one per page, pointing at the version you want indexed.
- Pointing at a redirect. If the canonical URL 301s somewhere else, you have asked Google to index a page that does not exist at that address. Follow it through: the canonical target should return 200 directly.
- Canonicalising everything to the homepage. A template bug, usually. A site-wide canonical to “/” tells the crawler every page is a duplicate of the front page, and the rankings for the individual pages go with it.
It is a hint
Google treats rel=canonical as a signal to be weighed, not a directive to be obeyed — the documentation says so in as many words. The crawler also looks at internal links, sitemaps, redirects and content similarity, and it will sometimes pick a different canonical than the one you declared. When that happens, the usual cause is contradictory evidence: the duplicate is linked from the navigation, listed in the sitemap, and returns 200 while the canonical target is slower or noindexed.
The practical rule: make the tag true, then remove the reasons to doubt it. If a page should not be indexed at all, use noindex — a canonical tag pointing from a noindex page is a contradiction that resolves badly.
Where people get it wrong on purpose
- Pagination. Canonicalising page 2 to page 1 hides your second page of articles. Self-canonical each page, and link them with rel=next/prev for the reader's benefit even though crawlers ignore it.
- Faceted search. Colour filters and sort orders multiply URLs. Canonicalise to the base category only if the variants genuinely show the same products; otherwise you are deleting your long tail.
- Syndication. Cross-posting to dev.to or Medium without a canonical back means the copy competes with the original. Most platforms let you set it; it takes thirty seconds.
How to check a site in a minute
- View source on three pages: the homepage, an article, a category.
- Find
rel="canonical"and read the href. Is it absolute? Does it match the page you are on? - Fetch that href. If it returns anything other than 200, the tag is lying.
- Compare the canonical of a filtered URL with the canonical of the clean one. If they differ when they should not, that is a template bug.
Canonical & hreflang auditor does the first three steps for a URL you paste in, including the return status of the target and the hreflang set that has to agree with it.
The one-sentence version
A canonical tag is a statement that two URLs are the same document — write it as if it were true, because when it is not, the crawler can tell.