Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Took ~1,000 Pages From Hundreds of Rich Results Warnings to Zero

说明与用途

一段 PHP 脚本通过验证必需属性、@id 引用和 JSON‑LD 语法,自动检测并消除了约 1,000 页中的 Rich Results 警告,并集成到 CI 中以防止回归。

问题

Hundreds of Rich Results warnings appeared on ~1,000 pages of structured data because JSON‑LD references pointed to nodes that were never defined.

结果

The auditor reduced Rich Results warnings from hundreds to zero across ~1,000 pages and provides continuous protection against future regressions.

工作流

  • 1. Extract all <script type="application/ld+json"> blocks from each rendered HTML file.
  • 2. Run three checks: required properties, @id resolution, and JSON parse errors.
  • 3. First pass indexes all nodes with @id to build a definition map.
  • 4. Second pass walks each node recursively, validating internal @id references against the map.
  • 5. Emit errors for missing properties, unresolved references, or parse failures.
  • 6. Return exit code 0 if clean, 1 if errors, 2 if misuse.
  • 7. Integrate the script into CI so any new warning causes a build failure.

证据

Google flagged hundreds of Rich Results warnings across them.

来源

jsonld-schema-audit is one PHP file with no dependencies.

来源

The exit code ties it together: 0 when clean, 1 when there are errors, 2 for bad usage.

来源

  • 记录日期: 2026-10-13T10:41:26.603Z