Phần tử không hợp lệ kết thúc head trước các thẻ SEO
Trong Neova Chạy ngay từ lần crawl: không cần thiết lập gì.
Quy tắc được rà soát lần cuối ngày 17 tháng 10 năm 2026 · Hướng dẫn cập nhật ngày 17 tháng 10 năm 2026
Google chỉ đọc metadata từ một head hợp lệ và bỏ qua những gì nằm sau một phần tử không hợp lệ. Thẻ tiêu đề, canonical, robots hoặc hreflang đặt sau phần tử đó có thể bị bỏ sót.
Bạn có thể làm gì
Chuyển phần tử không hợp lệ vào body, hoặc đặt mọi thẻ SEO phía trên nó.
Vì sao Neova đánh dấu
Hướng dẫn metadata của Google nói họ bỏ qua mọi phần tử trong head nằm sau một phần tử không hợp lệ.
Chỉ title, meta, link, script, style, base, noscript và template thuộc về head; mọi thứ khác đều đóng head.
Thẻ tiêu đề, canonical, robots hay hreflang nằm sau phần tử đó có thể bị công cụ tìm kiếm bỏ sót.
This check fires when your <head> contains an element that doesn't belong there, a stray <div>, a <p>, an <img>, or even loose text. The stakes are blunt: browsers and Google auto-close the head the instant they hit an invalid element, so anything after that point, your canonical, your hreflang, your Open Graph tags, gets shoved into the body and silently ignored. Your meta robots lands there too; Google says it still respects a robots meta tag in the body, but other crawlers may not.
Why a Single Stray Tag Wipes Out Your Meta Tags
The HTML spec allows only a specific, short list of elements inside <head>. When a parser encounters anything else, it doesn't error out, it assumes you forgot to write </head><body> and closes the head for you, right there. Every valid <meta>, <link>, or <script> that came after the offending element is now parsed as body content. A <link rel="canonical"> in the body is not a canonical, it's decoration Google throws away. Same for hreflang. Meta robots is the exception: Google says it respects a robots meta tag in the body, though other crawlers may not. You didn't lose the tag; you lost its meaning.
Here is a real one, a tracking snippet dumped a <div> into the head, and the canonical below it died:
The browser rewrites that as if </head><body> sat right before the <div>. The canonical and robots tag are in the body now. To Google, this page has no declared canonical and no robots directive, it falls back to defaults and guesses.
The Only Elements Allowed in the Head
Allowed in <head>
What It's For
Common Invalid Intruders
<title>
Page title (exactly one)
<div>, <section>
<meta>
Charset, robots, viewport, OG/Twitter
<p>, loose text
<link>
Canonical, stylesheets, hreflang, icons
<img>, <a>
<style>
Inline CSS
<h1>, <h6>
<script> / <noscript>
JS and no-JS fallbacks
<iframe>, <table>
<base>
Base URL for relative links (at most one)
<button>, <form>
<template>
Inert markup fragment
unencoded &, <, or > as text
If it isn't in the left column, it terminates the head early. A frequent surprise: raw text, even a stray comment fragment or an ampersand outside a tag, counts as an intruder, because text nodes aren't allowed as direct children of <head> either.
How to Detect It
View Source vs. rendered DOM: open raw source (Ctrl+U) and read the head top to bottom looking for anything that isn't title/meta/link/style/script/base. Then open DevTools Elements and check where </head> actually sits in the parsed DOM, if it closed earlier than your source shows, the browser found an intruder. The gap between the two views is the tell.
GSC URL Inspection (rendered HTML): inspect the URL, open "View crawled page," and check whether Google's rendered head still contains your canonical and robots tags. If they've fallen into the body, Google is confirming the early-close for you.
Screaming Frog: crawl, then check whether canonicals and meta robots that should exist show as empty or "Missing." A template that clearly outputs a canonical but reports none across a URL group is a strong signal the head is closing early.
W3C validator or a linter: run the URL through an HTML validator; "Element X not allowed as child of element head" pins the exact intruder and line number faster than eyeballing.
How to Fix It
Find the first invalid element in the head and either move it into the body or delete it. Injected analytics and consent snippets are the usual culprits, a GTM container's <noscript><iframe> block belongs immediately after the opening <body>, not in the head. Corrected:
<head>
<meta charset="utf-8">
<title>Running Shoes</title>
<link rel="canonical" href="https://example.com/shoes/running/">
<meta name="robots" content="index, follow">
</head>
<body>
<div id="gtm-noscript"></div> <!-- moved into body -->
Then confirm the fix in the rendered DOM: reload, open DevTools, and verify </head> now closes after your last meta tag. Re-inspect in Search Console so Google re-renders and picks the canonical and robots directive back up. If a plugin or tag manager is injecting the intruder, fix it at the source, patching the output once won't survive the next template render.
False Positives and Edge Cases
Some checkers flag <noscript> or a <script> that itself contains markup-looking strings. Those are valid in the head, a <noscript> holding a <link> or <style> is legal, and a script's inner text isn't parsed as head children. If the tool flags one of these but your canonical and robots tags still resolve correctly in the rendered DOM, it's a false positive; verify with the DOM before you go rearranging templates. The real test is always: does </head> close where you expect in the parsed page?
FAQ
Why Does One Bad Tag Kill Everything After It and Not Just Itself?
Because the parser reacts to an invalid head child by inserting an implicit </head><body> at that spot. It's not skipping the one tag, it's declaring the head over. Everything downstream inherits body context, so all your remaining meta/link tags become inert.
Will Invalid Comments Break the Head?
Well-formed comments (<!-- ... -->) are fine in the head. A malformed comment or raw text that looks like a comment but isn't closed properly can spill into a text node and trip the early-close. When in doubt, validate.
My Canonical Is in the Source, Why Does Google Say It's Missing?
Because "in the source" and "in the head" aren't the same thing once an intruder closes the head early. Check the rendered DOM: if the canonical sits below the implicit </head>, Google reads it as body content and ignores it. This is one of the sneakier causes behind a missing canonical tag.
Does This Affect Meta Robots Too, or Only Canonicals?
Everything below the intruder is affected, canonical, meta robots, hreflang, viewport, Open Graph, the lot. If your robots directive fell into the body, Google says it still respects it, but other crawlers may fall back to indexing defaults, so move it back into the head. See the meta robots outside head check for the robots-specific symptom of the same root cause.
Where Should Injected Third-Party Markup Go Instead?
Non-head elements (iframes, noscript image beacons, divs) belong in the body, typically right after <body>. Only title, meta, link, style, script, base, and template are legal head children. For the full picture of how a broken head cascades into indexing problems, the canonical tags reference walks through discovery and consolidation once your tags actually parse.
Tìm lỗi này trên trang của bạn
Neova chạy mục kiểm tra này và mọi mục khác trong mỗi lần crawl, rồi viết cách sửa thành ticket cho nhóm của bạn.
Ứng dụng máy tính cho Mac, Windows và Linux
Tất cả 696 mục kiểm tra, mỗi mục kèm nguồn
Search Console và Analytics 4, kết nối chỉ đọc
Ticket sang Jira, Linear và Asana
Tải NeovaGói Desktop Free, hoặc dùng thử Solo miễn phí 14 ngày, không cần thẻ.