Beacon · SEO & discoverability
schema-beacon
Validate JSON-LD and microdata against schema.org and Google rich-result requirements, across your whole built site.
npm i -D @mrlouiswright/schema-beaconPublished to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).
What it checks
- Both formatsJSON-LD (arrays,
@graph, nested nodes,@idreferences and node merging across blocks) and microdata (itemscope,itemtype,itempropwith the right value per element:content,href,src,datetimeor text). - Google rich-result requirementsArticle, BlogPosting and NewsArticle; Product, Offer, AggregateOffer, AggregateRating and Review; BreadcrumbList; FAQPage, QAPage and HowTo; Recipe; Event; JobPosting; LocalBusiness and its subtypes; Organization; VideoObject…
- Value checksISO 8601 dates and durations, absolute and valid URLs, plain-number prices, ISO 4217 currencies, schema.org enumerations (
availability,itemCondition,eventStatus,eventAttendanceMode… - Vocabularyunknown types with did-you-mean suggestions (
Prodcut→Product), missing@context, and retired or restricted rich results (HowTo, FAQ) reported as info. - Outputtext, JSON, SARIF 2.1.0 and Markdown;
--fail-on; exit codes 0/1/2; allowlist entries with expiry dates.
Quick usage
CLI
npx schema-beacon dist
npx schema-beacon dist --fail-on medium --no-recommended
npx schema-beacon public --include "products/**" --sarif schema.sarif
API
import { check, isIsoDate, suggestType } from 'schema-beacon';
const report = check('dist');
console.log(report.info.types); // { Product: 12, BreadcrumbList: 40, ... }
suggestType('Prodcut'); // 'Product'
Every option is documented in the schema-beacon docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
schema-beacon:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false }
- run: npm ci && npm run build # produce the static site first
- uses: MrLouisWright/schema-beacon@v1
with:
path: dist
fail-on: high
sarif: schema-beacon.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: schema-beacon.sarif }