DEV Community

One Space Broke the JSON-LD Headline on 62 Pages

Katia Belokon on November 09, 2026

One of my page headings, Your <em>IP</em>, plainly, showed up in the JSON-LD as "Your IP , plainly". The same bug was in the structured...
Collapse
 
alexcodebytes profile image
Oleksandr •

The inline-vs-block boundary rule is the whole article. Most strippers get it wrong because

one

two

→ onetwo is the bug everyone remembers, so they over-correct in the other direction and turn everything into a space.

Your build-from-the-same-string suggestion is stronger than the headingText() function, though — if the visible heading and the JSON-LD headline come from one source, the stripper becomes irrelevant for that pair. Did you end up doing that, or did the 62 pages get fixed by patching the generator?

The false positives you flagged (Learn .NET, Wait ..., Bonjour !) are worth keeping in the regex as exceptions rather than removing the check — the space-before-punctuation rule catches real bugs far more often than it cries wolf.

The "visual QA only checks the page humans see" line is going in my notes.

Collapse
 
katiabelokon profile image
Katia Belokon •

Thanks! Today the JSON-LD headline equals the visible H1 on 201 of 212 pages that have one. The other 11 differ on purpose: for example, the home pages in four languages use a descriptive headline, and the methodology pages add the version number. So one string can't cover every page, and the equality test needs a short list of allowed exceptions. Agreed on the regex: keep it strict and list the exceptions.

Collapse
 
alexcodebytes profile image
Oleksandr •

That makes sense. A 201/212 match rate is a pretty strong baseline, and the fact that the remaining 11 differences are intentional is exactly why a blanket equality rule would be too simplistic.

I'd keep the strict default and make the exceptions explicit, ideally tied to page type and a documented reason rather than just maintaining a list of URLs. That way, if a new mismatch appears, it fails the check instead of silently becoming another accepted exception.

One additional safeguard: the test should verify that every exception still has a valid JSON-LD headline and a visible H1, even when they aren't identical.

Are you planning to make those exceptions part of an automated regression test, so future content changes can't accidentally expand the exception list?

Thread Thread
 
katiabelokon profile image
Katia Belokon •

Not yet. Today it's a check I ran by hand, not something that runs on every build. Your version is better than a URL list: tie each exception to a page type and a reason, and fail on anything new. The extra assertion that every exception still has a headline and an H1 is a good catch too, since "different on purpose" shouldn't turn into "missing".

Thread Thread
 
alexcodebytes profile image
Oleksandr •

That's a good distinction. I'd also make sure exceptions don't become permanent just because they were once justified. Page structures change, and an exception that made sense today might hide a real issue six months later.

Ideally, the check should validate both sides: new unexpected differences fail the build, while existing exceptions are still required to meet their original conditions. That way, the exception list becomes part of the test rather than a way around it.

Thread Thread
 
katiabelokon profile image
Katia Belokon •

Agreed. An exception that still passes after the page has changed is a hidden failure with a green checkmark. Making each exception keep proving its original reason is the part I hadn't thought through. Thanks for pushing on this.

Collapse
 
seotto profile image
seotto.com •

Funny how the whitespace collapse hides half the damage: the double space disappears and only the one before the comma survives, so at a glance it looks fine. Building the heading and the headline from one string is the fix I'd push hardest, since it removes the drift instead of testing for it. How did you spot it in the first place, Rich Results Test or just reading the JSON-LD by chance?

Collapse
 
katiabelokon profile image
Katia Belokon •

Neither Rich Results Test nor the Schema Markup Validator would have caught it: a stray space is valid Text, so they show the string and stay green. That's the uncomfortable part. What guards it now is the comparison from the post. I reran it today on all 404 pages in the sitemap: zero headline, name or description fields with a space before punctuation.

Collapse
 
hanin_mp profile image
Hanin Mp •

The equality check against the visible h1 is the strongest part, but on many sites the JSON-LD headline is meant to match the title tag instead, and the two intentionally differ (shorter h1, longer title). Worth allowing either source in the test so it does not train people to ignore failures. The other gap: if any client-side code rewrites headings after hydration, the built HTML passes while the rendered DOM drifts. Do you run the same assertion against the rendered page as well?

Collapse
 
katiabelokon profile image
Katia Belokon •

Good point, and my own site proves it: 11 of 212 pages have a headline that differs from the H1 on purpose, so an H1-only check would fail them every time. Accepting the title tag as a second source is a fair fix. On hydration, I checked today: on 37 pages rendered in a real browser, 20 of them with inline tags in the heading, the H1 after JavaScript was identical to the H1 in the built HTML. My headings are static, so the build check covers it. If a site rewrites headings client-side, the same two assertions can run in Playwright against the rendered DOM.