跳到正文
Skillpedia
网站与界面(前端)75k · #2935

meta-in-body

它能做什么

这项技能检查 meta 标签,例如 noindex、canonical、description 和 viewport,是否位于页面的 head 部分中。适用于希望搜索引擎和浏览器能读取这些标签的网页制作者。

适用场景

  • ✓当你请智能体检查页面 HTML 结构中是否有放错位置的标签的时候。
  • ✓当插件或脚本可能把 meta 标签加到了 body 中,而搜索指令似乎被忽略的时候。
  • ✓当页面意外被收录或被移除,你需要确认其 meta 指令位于正确位置的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/meta-in-body/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/meta-in-body/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我页面中的部分 meta 标签可能放错了位置。请帮我检查并修复。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会解析页面,查找位于 body 内或 head 结束之后的 meta 元素。然后它会把这些元素移到 head 中,或修改插入它们的脚本,使其指向 head。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Meta Tags in Body

Meta tags placed in the document body are ignored by search engines and most browsers—directives like noindex or canonical-url are silently ineffective, causing pages to be indexed or de-indexed unexpectedly.

Quick Reference

  • All <meta> tags must appear inside <head>, never inside <body>
  • Browsers may ignore or move misplaced meta tags, making them ineffective
  • Crawlers like Googlebot only process meta tags found in <head>
  • Validate with HTML validator or inspect parsed DOM to confirm placement

Check

Parse the HTML and check whether any <meta> elements appear outside <head>—i.e., inside <body> or after the </head> closing tag. Flag each misplaced tag by name/property.

Fix

Move all <meta> tags into the <head> section before </head>. If they are injected by a script after the DOM is built, refactor the injection to target document.head instead of document.body.

Explain

Meta tags are document-level metadata and must live in <head>. When placed in <body>, they fall outside the metadata model of the document—search engines and browsers do not honour them, so directives like noindex or canonical-url will have no effect.

Code Review

Parse the rendered HTML and check the DOM structure. Find all <meta> elements. For each one, traverse up the parent chain — if any ancestor is <body> or if the element appears after </head> in the source, flag it. Pay special attention to: meta name='robots', meta name='description', meta property='og:*', and link rel='canonical' placed in body.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/seo/meta-in-body

常见问题

放错位置的 meta 标签为什么重要?

搜索引擎和浏览器可能会忽略它们,因此 noindex 或 canonical 等指令将不起作用。

如果是脚本添加的标签怎么办?

这项技能建议修改脚本,把标签添加到文档的 head 中,而不是 body 中。

如何检查位置是否正确?

这项技能建议使用 HTML 验证器,或检查解析后的页面结构。

详情

作者的原始描述

Use when auditing HTML document structure. Applies to any page where meta tags (noindex, canonical-url, description, viewport, OG tags) may have been injected into the body by CMS plugins, widgets, or JavaScript rendering.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2935
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能