Beacon · SEO & discoverability
sitemap-beacon
Audit XML sitemaps against your built static site: every URL should be a real, indexable, canonical page, and every such page should be listed.
npm i -D @mrlouiswright/sitemap-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
- Discovery
sitemap.xml,sitemap_index.xml,sitemap-*.xml,.xml.gz, and the files named inSitemap:lines in robots.txt. Sitemap indexes are followed to their children, and missing children are reported. - Protocolvalid
<urlset>/<sitemapindex>root and namespace, 50,000-URL and 50 MB limits, absolute and properly escaped<loc>, duplicates, and validchangefreq/priority(which Google ignores; reported as info). - Each URL vs the buildno page at that URL (or only a meta-refresh stub or an error page),
noindexfrom meta robots or fromX-Robots-Tagin_headers/vercel.json, canonicalised to a different URL, or another host or protocol. - lastmodinvalid W3C datetime, in the future, older than the page's own
dateModified/article:modified_time, the same on every URL (a build timestamp), and an optional maximum age. - Coverageindexable, self-canonical pages that are not in any sitemap. Use
notInSitemapglobs for pages you leave out on purpose. - Outputtext, JSON, SARIF 2.1.0 and Markdown;
--fail-on; exit codes 0/1/2; allowlist entries with expiry dates.
Quick usage
CLI
npx sitemap-beacon dist
npx sitemap-beacon dist --base-url https://example.com --fail-on medium
npx sitemap-beacon public --sitemap sitemap-index.xml --max-age-days 730
npx sitemap-beacon out --clean-urls --not-in-sitemap "/tags/**,/page/*"
API
import { check, parseSitemap } from 'sitemap-beacon';
const report = check('dist', { maxAgeDays: 365 });
console.log(report.info.sitemaps, report.info.urls);
parseSitemap(xml).entries; // [{ loc, lastmod, changefreq, priority, line }]
Every option is documented in the sitemap-beacon docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
sitemap-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/sitemap-beacon@v1
with:
path: dist
fail-on: high
sarif: sitemap-beacon.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: sitemap-beacon.sarif }