Canonical tag mistakes: what we found on 441 sites, and how to check yours
A canonical link (<link rel="canonical" href="…">) tells search engines which URL is the real one when the same page answers at several addresses: with and without a trailing slash, with www and without, with ?utm_ parameters. Google treats it as a strong hint, not a rule. When the canonical contradicts other signals, such as a redirect, Google picks a URL itself.
On 27 November 2026 we fetched 914 inner pages (not home pages) on 441 company and docs sites from our audits: two pages each on 394 sites picked at random from 4,250, plus every site where an earlier audit had found inner pages pointing their canonical at the home page. On the 394 random sites:
- The canonical pointed at a URL that redirects: 43 sites (11%). On 32 of them the only difference was the trailing slash.
- No canonical on a page we fetched: 47 sites (12%).
- Other mistakes (every page pointing at the home page, a relative path that resolves to the wrong page, a double slash, a staging path, a tag in
<body>): 13 sites.
So roughly one site in four had a canonical problem on an ordinary inner page. Most of them are one setting away from fixed.
1. The canonical points at a redirect
The page answers at one URL, its canonical names another, and that other URL redirects back. The search engine gets two opposite answers to "which URL is the real one?". What we saw:
- Trailing slash (32 sites). The page is served at
/blog/authors/, the canonical says/blog/authors, and the server redirects/blog/authorsto/blog/authors/. Or the reverse. Most static hosts serveabout/index.htmlat/about/and redirect/aboutthere, while the site generator builds the canonical without the slash. wwwor not (6 sites). The canonical sayshttps://www.example.com/…, the server redirectswwwto the bare domain (or the reverse).- The rest: a canonical with
http://on a site that redirects tohttps://, and canonicals that still name a domain the site moved away from.
The fix is to make the generator, the host and the canonical agree on one form:
- Astro: set
siteto the exact production origin andtrailingSlashto"always"or"never"to match your host, and build the canonical asnew URL(Astro.url.pathname, Astro.site). See Open Graph tags in Astro. - Docusaurus: set
trailingSlashexplicitly; Docusaurus uses it for canonical URLs and the sitemap. See SEO for Docusaurus. - Hugo:
baseURLwith the production scheme and host (wwwor not), and{{ .Permalink }}as the canonical. Joining.Site.BaseURLand a path by hand is how sites end up withhttps://example.com//posts/…. See Hugo SEO. - Next.js:
trailingSlashinnext.config.jsand per-pagealternates.canonicalin the same form, withmetadataBaseset to the production origin. See Next.js SEO. - Webflow: Site settings → SEO → Global canonical tag URL must be your default domain, with
https://, the samewwwchoice as in Publishing, and no trailing slash (a slash there gives every page//). See Webflow SEO. - WordPress: core builds the canonical from Settings → General → Site Address (URL). It must be the
httpshost your server redirects to. See SEO for WordPress.
2. No canonical on inner pages
47 of the 394 sites had a page without one. Often the home page has a canonical and the blog posts or docs pages don't, because the tag was added to one template. Without it, every copy of a page (with tracking parameters, with or without the slash) competes on its own. The fix is the same as above: add the tag in the shared layout, built from the page's own URL, so every page gets one.
3. Every page says it's the home page
An earlier audit found 48 sites whose inner pages named the home page as their canonical. When we fetched them again, 35 had fixed it and 7 still did it on every page we checked; 3 more sites in the random sample did the same. It usually comes from a hard-coded href="https://example.com/" in the layout, or a site-wide canonical setting in a theme. Google mostly ignores a canonical that points at a different page, but a page that tells it "the real version is the home page" is asking not to be indexed.
4. Smaller mistakes
- Relative paths.
href="/blog/post/"is allowed and works.href="../../tools/"is easy to get wrong: on 3 of 4 sites with relative canonicals the path resolved to a different page. Use an absolute URL. - A staging or old path left in the canonical, such as
/staging/5316/2020/10/29/…from a migration. - Translated pages pointing at the English page. If the translation is a real page, give it a canonical to itself and link the languages with
hreflang; a canonical to English tells Google not to index the translation. - Old docs versions pointing at the latest version (
/docs/1.11.0/…→/docs/latest/…). That one is deliberate and fine, as long as the page exists in the latest version.
5. Check your site
This script reads your sitemap (or a single page URL), fetches up to 50 pages and reports missing, empty, duplicate, relative and <body> canonicals, canonicals that point at the home page, canonicals that redirect or don't answer 200, and sitemap URLs that redirect. Save it as check-canonical.mjs and run node check-canonical.mjs https://example.com/sitemap.xml (Node 20 or later; a second argument changes the page limit). Canonicals that point at a different page that answers 200 are listed but not counted as errors, because that can be deliberate. It exits with 1 when it finds a problem.
const [start, max = 50] = process.argv.slice(2);
const get = (u, redirect = "follow") => fetch(u, { redirect, headers: { "user-agent": "check-canonical" } });
let pages = [start];
if (/\.xml($|\?)/.test(start)) {
const locs = async (u) => [...(await (await get(u)).text()).matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1].replaceAll("&", "&"));
pages = await locs(start);
if (pages.every((u) => /\.xml($|\?)/.test(u))) pages = (await Promise.all(pages.slice(0, 5).map(locs))).flat();
}
let bad = 0;
const say = (url, msg) => { console.log(msg.padEnd(34), url); bad++; };
for (const url of pages.slice(0, Number(max))) {
const res = await get(url);
if (res.url !== url) say(url, `listed URL redirects to ${res.url}`);
const html = await res.text();
const headEnd = html.search(/<\/head>|<body[\s>]/i);
const tags = [...html.matchAll(/<link\b[^>]*>/gi)].filter((m) => /\brel=["']?canonical\b/i.test(m[0]));
if (!tags.length) { say(res.url, "no canonical"); continue; }
const hrefs = tags.map((m) => /\bhref=(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(m[0])).map((h) => (h?.[1] ?? h?.[2] ?? h?.[3] ?? "").trim());
if (new Set(hrefs).size > 1) say(res.url, `${hrefs.length} different canonicals`);
if (headEnd >= 0 && tags[0].index > headEnd) say(res.url, "canonical is in <body> (ignored)");
if (!hrefs[0]) { say(res.url, "empty canonical"); continue; }
if (!/^https?:\/\//i.test(hrefs[0])) say(res.url, `relative canonical ${hrefs[0]}`);
const target = new URL(hrefs[0], res.url).href;
if (target === res.url) continue;
if (new URL(target).pathname === "/" && new URL(res.url).pathname !== "/") { say(res.url, "canonical is the home page"); continue; }
const t = await get(target, "manual");
if (t.status >= 300 && t.status < 400) say(res.url, `canonical ${target} redirects (${t.status}) to ${new URL(t.headers.get("location"), target).href}`);
else if (t.status !== 200) say(res.url, `canonical ${target} answers ${t.status}`);
else console.log("canonical points elsewhere".padEnd(34), res.url, "->", target);
}
process.exitCode = bad ? 1 : 0;
We tested it on live pages showing each of the mistakes above and on test pages for the rest. To look at one page with everything else around it (title, description, link previews, robots), paste the URL into the free SEO checker.
Automating it with Headlark
Headlark's build step adds a canonical to pages that don't have one, from the page's own URL, along with the title, description, Open Graph and X tags and structured data. A canonical you already set is kept as it is, so the settings above are still yours to get right.
Try it
Try it free for 14 days on one site and up to 500 pages, no card needed. Add your site.