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:

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:

The fix is to make the generator, the host and the canonical agree on one form:

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

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("&amp;", "&"));
  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.