CI/CD Schema Testing: Catching Broken JSON-LD & Empty Canonicals Before Deploy
One stray trailing comma or unescaped quote in CMS-injected JSON-LD breaks rich results site-wide for months until someone checks Search Console.
Dmitry K., Technical SEO Lead · SEO Space
1. Why Manual Schema Testing Fails in Fast Engineering Teams
Frontend teams push dozens of pull requests every week—refactoring headers, updating CMS serializers, or adjusting route prefixes. Without automated SEO tests in CI, a single accidentally injected `noindex` tag, trailing-comma JSON-LD syntax error, or missing `canonical` slips silently into production.
Adding a 4-second post-build Node verification script catches 95% of catastrophic technical SEO regressions before code ever touches production.
- Parse every `<script type="application/ld+json">` node on representative templates via `JSON.parse()` during build.
- Assert that every internal `@id` reference resolves cleanly inside the `@graph` array.
- Verify presence of exactly one `<h1>`, non-empty `<title>`, `<meta name="description">`, and `index, follow` on commercial builds.
2. Zero-Dependency Post-Build SEO Regression Script
Run a fast static check right after Vite/Next.js pre-rendering finishes in CI to fail broken deployments immediately.
Explicitly assert in production CI checks that `robots.txt` never contains `Disallow: /` and HTML headers never carry unintended `noindex` directives.
| CI Check Category | What It Catches | Execution Time |
|---|---|---|
| JSON-LD Syntax & @graph check | Bad CMS escapes, missing fields | < 0.5 seconds |
| Canonical & Hreflang Parity | Self-ref loops, missing x-default | < 1.0 second |
| Broken Internal Link Scanner | 404 typos in new articles/menus | < 1.5 seconds |
// Example CI post-build SEO gate (scripts/audit-seo.mjs)
for (const htmlFile of builtRoutes) {
const html = fs.readFileSync(htmlFile, 'utf8');
const ldMatch = html.match(/<script[^>]*type="application\/ld\+json"[^>]*>([\s\S]*?)<\/script>/i);
if (!ldMatch) throw new Error(`Missing JSON-LD on ${htmlFile}`);
JSON.parse(ldMatch[1]); // Fails immediately on trailing commas or bad quotes
if ((html.match(/<h1[\s>]/gi) || []).length !== 1) {
throw new Error(`Invalid H1 count on ${htmlFile}`);
}
} Need this indexation setup audited on your domain?
Send your website URL. We check raw HTML parity, log crawl hits, canonical discipline, and sitemap architecture manually within 24 hours.