json-ld-valid
它能做什么
这个技能检查页面上的结构化数据代码块是否有语法错误或缺少必填字段。它面向希望获得富媒体搜索结果的网站所有者和开发者。
适用场景
- ✓你的富媒体结果没有出现在 Google Search Console 中的时候。
- ✓你在页面中添加文章、产品、常见问题或面包屑标记的时候。
- ✓你用代码或模板生成结构化数据的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/json-ld-valid/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查结构化数据,并告诉我富媒体结果为什么没有显示吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会解析每个 JSON-LD 代码块,检查上下文和类型,并验证该类型所需的属性。它会建议修复语法错误和缺失字段,并推荐 Google 的富媒体结果测试工具。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use valid JSON-LD structured data
Invalid JSON-LD is silently ignored by Google — there are no error messages in search results, only the absence of rich results. Invalid structured data means no eligibility for rich results (stars, FAQs, breadcrumbs, etc.) that increase click-through rates.
Quick Reference
- JSON-LD must be valid JSON, reference
@context: 'https://schema.org', and include all required properties for the chosen@type - Invalid JSON (unclosed brackets, missing commas) causes the entire block to be silently ignored by Google
- Validate with Google's Rich Results Test before deploying structured data changes
Check
Find all <script type='application/ld+json'> elements on the page. For each: (1) Attempt to parse the content as JSON — flag syntax errors. (2) Verify @context is set to 'https://schema.org'. (3) Verify @type is a valid schema.org type. (4) For the detected type, check required properties are present (e.g., Article requires headline, author, datePublished; Product requires name; FAQPage requires mainEntity). (5) Run through Google's Rich Results Test API if available.
Fix
- Parse the JSON-LD with
JSON.parse()— fix any syntax errors (trailing commas, single quotes, missing brackets). - Ensure
@contextis exactly"https://schema.org"(not"http://schema.org"or omitted). - Verify the
@typevalue against schema.org types. - Add required properties for the type:
- Article: headline, author (with @type Person and name), datePublished
- Product: name (and ideally offers, description)
- FAQPage: mainEntity array with Question and acceptedAnswer
- BreadcrumbList: itemListElement array with ListItem, position, name, item
- Validate at https://search.google.com/test/rich-results
- Validate JSON syntax at https://jsonlint.com
Explain
Google uses JSON-LD structured data to generate rich results — enhanced search result formats that include stars, images, expandable Q&As, and other features. Invalid JSON-LD is ignored entirely: no rich results are generated, and no error is reported to you. Only by testing with the Rich Results Test can you discover validation failures. Correct, complete JSON-LD is a prerequisite for rich result eligibility.
Code Review
Extract all <script type='application/ld+json'> element contents. Run JSON.parse() on each — catch and report parse errors. Validate that @context equals 'https://schema.org'. Check @type against a whitelist of common valid types. For each type, validate required properties are present and non-empty. Report the first validation error found for each block.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/seo/json-ld-valid
常见问题
Google 会对无效的结构化数据显示错误吗?
这个技能说,无效的 JSON-LD 会被无声忽略,唯一的迹象就是富媒体结果不出现。
常见的语法问题有哪些?
这个技能提到,多余的逗号、单引号和缺少的括号是常见原因。
如何测试标记?
这个技能建议在发布更改之前,先用 Google 的富媒体结果测试工具检查。
详情
作者的原始描述
Use when generating or auditing any `<script type='application/ld+json'>` blocks, implementing structured data for articles, products, FAQs, breadcrumbs, or local businesses, or investigating why rich results are not appearing in Google Search Console.
热度
- GitHub 星标
- 75k
- 排名
- #2906
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。