Skip to Content

Canonical tag outside the head

What it is

The page has a canonical tag, but no <link rel="canonical"> sits inside the <head>. Often the tag was written in the head, but an element that does not belong there, such as an image, an iframe, a <div> or stray text, closed the head early, so every tag after it became part of the body. Sometimes a page builder simply places it in a body code block.

Why it matters

Google accepts a canonical only in the head , and says it stops reading the head  at the first invalid element. The canonical is then ignored and Google chooses the main URL itself, as if the page had none. The same early break can hide the title, meta description, robots tag and hreflang links written after it.

How Asky checks it

Asky parses the page’s raw HTML the way a browser does. A tag placed between </head> and <body> is moved back into the head by the parser and is not reported, while an invalid element in the head closes it and pushes everything after it into the body. The page is reported when it has at least one canonical tag with an address and none of those is in the head. Content added by JavaScript is not seen. A second canonical in the body next to one in the head is reported as multiple canonicals instead. The same break often also raises the title, meta description, robots tag or hreflang outside-head issues.

Reported as an error with high severity.

How to fix it

  1. Open the page in the browser’s element inspector, which shows where the parser placed each tag, and compare it with the page source.
  2. If the canonical is written inside the head in the source, look above it for the element that ended the head: often an <img> tracking pixel, an <iframe>, a <div> from a consent or chat widget, or text left by a broken tag.
  3. Move that element into the <body>. If a vendor script insists on the head, place it after the title, meta and link tags.
  4. If the canonical itself is written in the body, for example in an embed block, delete it there and set it through the page’s SEO settings or the head custom code field (in Webflow, Inside <head> tag in the page settings, or Head code under Site settings > Custom code).
  5. Keep a single canonical tag, pointing to the page’s full https:// URL.
  6. Check the page’s other head tags in the inspector too, since the same break moves them.

Example

On https://example.com/blog/pricing-guide, a tracking pixel in the head closes it before the canonical:

<!-- Before --> <head> <title>SaaS Pricing Guide: Models and Examples</title> <img src="https://example.org/pixel.gif" alt=""> <link rel="canonical" href="https://example.com/blog/pricing-guide"> </head> <!-- After: the pixel moves to the body --> <head> <title>SaaS Pricing Guide: Models and Examples</title> <link rel="canonical" href="https://example.com/blog/pricing-guide"> </head> <body> <img src="https://example.org/pixel.gif" alt=""> </body>

← Back to Canonicals

Last updated on