Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 2.37 KB

File metadata and controls

64 lines (50 loc) · 2.37 KB

validate-jsonld

SEO deploy gate — extract every JSON-LD block and assert it is valid JSON, a valid schema.org shape, and (optionally) consistent with the page.

What it catches

  • Invalid JSON — a trailing comma or unquoted key that silently disables your rich result. (JSONLD_INVALID_JSON)
  • Invalid schema.org shape — e.g. a Product with no name, or a price that's an object instead of a string/number. (JSONLD_SCHEMA_INVALID)
  • Markup that lies (consistency mode) — the JSON-LD declares a Product.name / Article.headline that doesn't appear in the rendered body. (JSONLD_INCONSISTENT)
  • Plus notices/warnings for nodes with no @type (JSONLD_NO_TYPE), unknown types with no shipped schema (JSONLD_UNKNOWN_TYPE), and pages with no JSON-LD at all (JSONLD_NONE).

Shipped schemas

Pragmatic JSON Schema subsets for the rich-result types Google acts on: Product, Article, BreadcrumbList, Organization, FAQPage. They assert required fields and field shapes — not the entire schema.org vocabulary. Unknown @types are reported as a notice and skipped, never failed.

Usage

- uses: nimajafari/seo-ci/actions/validate-jsonld@v1
  with:
    urls: |
      https://www.example.com/products/widget
      https://www.example.com/blog/launch-post
    consistency: true   # also assert the markup matches the page body

Against build artifacts:

- uses: nimajafari/seo-ci/actions/validate-jsonld@v1
  with:
    urls: |
      ./dist/products/widget/index.html

Inputs

Input Default Description
urls — (required) URLs or HTML file paths, one per line (JSON array accepted).
consistency false Assert declared fields appear in the rendered body.
strict false Treat warnings as errors.
report-path "" Write the JSON report to this path.

Outputs

passed, errors, warnings, notices, report — see the top-level README.

Caveat: A starting point, not a drop-in guarantee. The shipped schemas are a curated subset; extend schemas/ for your types. Consistency mode compares against server-rendered HTML — JSON-LD injected client-side won't be seen here (and Google may treat it differently). Never describe content to crawlers that users can't see; that's cloaking.