Beacon · SEO & discoverability
heading-beacon
Audit the heading structure of your built static site.
npm i -D @mrlouiswright/heading-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
- H1missing, more than one, hidden, very short, sharing no words with the
<title>, and the same H1 on several pages. - Hierarchyskipped levels (
<h2>→<h4>), lower-level headings before the H1 in the main content (headings in<header>,<nav>,<aside>and<footer>are ignored), and long pages with no<h2>. - Qualityempty headings (including images without alt), image-only headings, generic or keyword-empty text ("Introduction", "Read more", "Section 3", lorem ipsum, plus your own list), duplicates at the same level, and overlong headings.
Quick usage
CLI
npx heading-beacon dist
npx heading-beacon dist --fail-on medium
npx heading-beacon _site --max-length 90 --generic "Our services,Learn more"
npx heading-beacon out --allow-multiple-h1 --format markdown > headings.md
API
import { check, isGeneric } from "heading-beacon";
const report = check("dist", { maxLength: 100 });
console.log(report.counts);
isGeneric("Introduction"); // true
Every option is documented in the heading-beacon docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
heading-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/heading-beacon@v1
with:
path: dist
fail-on: high
sarif: heading-beacon.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: heading-beacon.sarif }