Sub topic 14
Common canonical mistakes and conflicting signals
This chapter assumes you can already write a rel=canonical link element, send it as an HTTP header, and choose a canonical target. It also assumes you know the basic status codes (200, 301, 404) and how noindex and robots.txt differ. Here you will learn the errors that make search engines ignore a canonical, and how to find and fix them.
Why a canonical is a hint
A canonical is a hint, not a command. Google collects many signals about which URL in a duplicate cluster should represent it. Those signals include redirects, rel=canonical, sitemap entries, internal links, HTTPS versus HTTP, and URL cleanliness. The canonical tag is a strong signal, but it can lose to the others. Most "Google ignored my canonical" reports come from signals that disagree.
Mistakes fall into two groups. Some make the tag unusable, so the crawler cannot read it. Others make it contradict the rest of your site.
Mistakes that make the tag unusable
Placing the tag outside the head
Search engines read rel=canonical only in the <head>. A parser that meets a body-only element such as <div> or <p> closes the head early. Any canonical after that point is then in the body and is ignored. Common causes are a broken tag, an unescaped quote, or a plugin that injects markup too early.
<head>
<title>Trail Running Shoes for Beginners | Example Store</title>
<script>document.write("<div></div>");</script>
<link rel="canonical" href="https://www.example.com/shoes/trail-running">
</head>In this example, the parser treats the injected <div> as the start of the body. Check the rendered HTML, not only your template.
Using relative or malformed URLs
A relative href such as /shoes/trail-running can resolve to the wrong host or protocol, for example on a staging domain or through a proxy. Use an absolute URL with protocol and host. Other malformed values include a missing scheme (www.example.com/shoes), spaces, and a URL that includes a fragment.
Emitting more than one canonical
A theme and an SEO plugin may each print a canonical. When the two values differ, search engines may ignore both. Make sure each page has exactly one, whether in the HTML or in the HTTP header. If you use both, they must match.
Relying on JavaScript to inject the canonical
Google can render JavaScript and read a canonical added by script, but this is slower and less reliable. If the raw HTML contains one canonical and the script changes it to another, the signals conflict. Put the canonical in the server-rendered HTML.
Mistakes in the target
Pointing to a URL that does not return 200
The target should be indexable and return a 200 status. These targets cause trouble:
- A URL that returns 404 or 410. The hint points to a page that does not exist.
- A URL that redirects with a 301. The canonical should be the final destination.
- A URL with
noindex. This tells the engine both "index this one" and "do not index this one." - A URL blocked by
robots.txt. The crawler cannot fetch it to confirm the relationship.
Building chains and loops
Page A canonicalizes to B, and B canonicalizes to C. Engines may follow a chain only a short way, then pick a URL on their own. A loop (A to B, B to A) gives no usable answer. Every page in a cluster should point directly to the same final URL, and that URL should canonicalize to itself.
Canonicalizing to unrelated content
Pointing every product page, category page, or paginated page to the homepage is a classic mistake. The content differs, so engines treat the hint as unreliable and may disregard it. When that happens, the homepage can end up receiving the duplicates' signals, while the real pages may drop out of the index. A canonical should connect pages whose main content is the same or nearly the same.
Pagination is a related case. Pointing page 2 and page 3 of a list to page 1 hides the items that appear only on those pages. Let each paginated page canonicalize to itself unless you offer a real "view all" page.
Dropping parameters that change content
Stripping utm_source is safe. Stripping ?color=red or ?page=2 can merge pages that are genuinely different. Before you add a parameter to a removal list, load the URL with and without it and confirm the visible content is the same.
Conflicts between signals
Even a perfect tag can lose when other signals point elsewhere.
| Conflict | What happens | Fix |
|---|---|---|
| Canonical says URL A, but a 301 sends A to B | Redirect and canonical disagree. The redirect usually wins. | Point the canonical at B |
| Canonical says A, but the sitemap lists B | Mixed signals weaken the hint | Put only canonical URLs in the sitemap |
| Canonical says A, but most internal links use B | The engine may choose B | Link internally to the canonical URL |
| Canonical on an HTTPS page points to HTTP | The engine often prefers HTTPS anyway | Use HTTPS everywhere and redirect HTTP |
| Canonical plus `noindex` on the same page | The page may drop from the index, and the hint may be lost with it | Choose one: consolidate or remove |
| Canonical A, but hreflang references B | Language alternates break | Make hreflang URLs match canonical URLs |
| Canonical points to a `robots.txt`-blocked URL | The crawler cannot verify it | Unblock the target |
Redirects and canonicals interact in a second way. A canonical on a page that itself redirects is never read, because the crawler follows the redirect first. Put the canonical on the destination page.
The following diagram shows how an engine ends up choosing a canonical.
Diagnosing a canonical problem
- Inspect the URL in Search Console. The URL Inspection tool shows the "User-declared canonical" and the "Google-selected canonical." If they differ, signals conflict.
- Read the Page indexing report. Statuses such as "Duplicate, Google chose different canonical than user" and "Alternate page with proper canonical tag" tell you which pages are affected.
- Compare raw and rendered HTML. View source, then compare it with the rendered DOM in the inspection tool. A difference suggests script-injected or relocated tags.
- Check headers. Use
curl -Ito see whether aLink: rel="canonical"header disagrees with the HTML tag. - Follow the target. Confirm it returns 200, is not blocked, and has no
noindex.
The script below automates steps 3 to 5 for one URL. It needs Node 18 or later and uses the built-in fetch.
// check-canonical.mjs
// Usage: node check-canonical.mjs https://www.example.com/shoes/trail-running
const pageUrl = process.argv[2];
if (!pageUrl) {
console.error("Usage: node check-canonical.mjs <url>");
process.exit(1);
}
const res = await fetch(pageUrl);
const html = await res.text();
const head = html.split(/<\/head>/i)[0];
const tags = [...head.matchAll(/<link\b[^>]*rel=["']canonical["'][^>]*>/gi)];
const hrefs = tags
.map((m) => m[0].match(/href=["']([^"']*)["']/i))
.filter(Boolean)
.map((m) => m[1]);
if (hrefs.length === 0) console.log("PROBLEM: no canonical in <head>");
if (hrefs.length > 1) console.log("PROBLEM: multiple canonicals:", hrefs);
for (const href of hrefs) {
if (!/^https?:\/\//i.test(href)) console.log("PROBLEM: not absolute:", href);
const target = await fetch(href, { redirect: "manual" });
if (target.status !== 200) {
console.log(`PROBLEM: target ${href} returned ${target.status}`);
}
const robots = target.headers.get("x-robots-tag") || "";
if (/noindex/i.test(robots)) console.log("PROBLEM: target sends noindex header");
}
console.log("Checked", pageUrl, "->", hrefs.length ? hrefs.join(", ") : "none");The script does not check for a noindex meta tag on the target, robots.txt blocking, or JavaScript-injected tags. Use Search Console for those.
Fixing conflicts in practice
Start with the signal you control most directly. Update internal links and the sitemap so they list only canonical URLs. Then correct the tag or the redirect. After that, request re-indexing for a few key pages and wait. Engines need to recrawl and recompute clusters, which can take days or weeks. Do not toggle the tag back and forth during that time, because every change resets the evidence.
Exercise
A product page at https://www.example.com/shoes/trail-running has a canonical pointing to https://www.example.com/shoes/trail-running/ (with a trailing slash). That URL answers with a 301 redirect back to the version without the slash. Search Console reports "Google chose different canonical than user." What is the conflict, and how do you fix it?
Show answer
The canonical points to a URL that redirects, and the redirect points back to the original page. The redirect and the canonical disagree, which forms a loop. Choose one form (here, no trailing slash). Make the canonical tag, internal links, sitemap entries, and redirect rules all use that form. The canonical should then be https://www.example.com/shoes/trail-running, which returns 200 and canonicalizes to itself.
Exercise
A site's theme prints a canonical, and an SEO plugin prints another one with a different URL on the same page. What are the likely outcomes, and what is the fix?
Show answer
Search engines may ignore both tags and pick a canonical themselves, which can produce an unwanted URL in results. The fix is to leave only one source of canonical output, either by disabling the theme's tag or by configuring the plugin, and to confirm in the rendered HTML that exactly one canonical remains.