Skip to Content
OpportunitiesTechnicalIssue ReferenceDirectivesRobots meta tag outside the head

Robots meta tag outside the head

What it is

The page has a robots meta tag, <meta name="robots"> or the Google-only <meta name="googlebot">, but none sits inside the <head>. This tag tells search engines whether to index the page and follow its links. It usually lands in the body because an element that does not belong in the head, such as an image, an iframe or a <div>, closed the head early, or because a page builder put it in a body code block.

Why it matters

Google says to place the robots meta tag in the head , and that it stops reading the head  at the first element that does not belong there. It does not document how it treats a robots tag found later in the page, so the page’s indexing rests on behaviour you cannot see: a noindex meant to hide a page might not be applied. The same early break can hide the canonical, title and hreflang tags written after it.

How Asky checks it

Asky parses the page’s raw HTML the way a browser does and looks for robots and googlebot meta tags anywhere in it, with the name in any letter case. The page is reported when at least one exists and none is inside the head. A tag written between </head> and <body> is moved into the head by the parser and is not reported. Tags for other crawlers and the X-Robots-Tag HTTP header are not read. Every robots and googlebot tag still counts for the noindex, nofollow and other directive issues, wherever it sits. The same break often raises the canonical, title, meta description or hreflang outside-head issues too.

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 robots tag is written inside the head in the source, look above it for the element that ended the head: an <img> tracking pixel, an <iframe>, a <div> from a 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 all meta and link tags.
  4. If the robots tag itself is written in the body, delete it there and set the rule through the page’s SEO settings or plugin, or the head custom code field.
  5. Once the tag is in the head, read its rules again: they now apply in full, so remove a leftover noindex or nofollow if the page should be found.
  6. Keep one robots tag where you can. Asky combines every robots and googlebot tag, as Google does, and Google applies the more restrictive rule when they conflict, so a forgotten second tag still counts.

Example

On https://example.com/blog/pricing-guide, a chat widget’s <div> in the head closes it before the robots tag:

<!-- Before --> <head> <title>SaaS Pricing Guide: Models and Examples</title> <div id="chat-widget"></div> <meta name="robots" content="max-image-preview:large"> </head> <!-- After: the widget moves to the body --> <head> <title>SaaS Pricing Guide: Models and Examples</title> <meta name="robots" content="max-image-preview:large"> </head> <body> <div id="chat-widget"></div> </body>

← Back to Directives

Last updated on