Skip to content

Fix double-encoded values in enhanced JSON-LD - #4229

Merged
matthewhelmke merged 1 commit into
mainfrom
fix-learning-lab-jsonld
Oct 16, 2026
Merged

matthewhelmke merged 1 commit into
mainfrom
fix-learning-lab-jsonld

Conversation

@matthewhelmke

Copy link
Copy Markdown
Collaborator

Summary

The HowTo, TechArticle, and LearningResource JSON-LD blocks render every string value wrapped in literal quotes, so search engines read the quotes as part of the value. From the November 2025 Learning Lab page:

"name":"\"Chainguard OS on Raspberry Pi\"",
"datePublished":"\"2025-11-21T17:00:00Z\""

This PR removes jsonify from layouts/partials/head/enhanced-structured-data.html and lets Go's html/template encode the values, as structured-data.html already does. Hugo's jsonify returns template.HTML, and inside a <script type="application/ld+json"> block html/template JSON-encodes that result a second time.

Affected pages

Schema Pages
HowTo 40
LearningResource (Learning Labs) 12
TechArticle 8

The FAQPage and SoftwareApplication blocks used the same pattern but match no pages today. They're fixed too, so they render correctly if a page starts matching.

Testing

I built main and this branch with hugo --gc --minify and compared the output:

  • All 1,041 ld+json blocks parse with json.loads, and none has a value wrapped in quotes. On main, 60 did.
  • On each of the 60 pages, this branch's values equal main's values decoded once more. The content is unchanged; only the extra encoding is gone.
  • No URL picks up \/ escaping.
  • No other output changed except build noise: generation timestamps in ai-metadata.json, ai-sitemap.json, concepts.json, and llms-full.txt, and the policy-controller tag title, which flips between Policy-Controller and Policy Controller from build to build because content uses both spellings.

I didn't use printf "%q" | safeJS. safeJS turns off the escaping that keeps a </script> in a title from closing the block, and %q can emit Go escapes such as \x01, which aren't valid JSON.


🤖 Generated with Claude Code

Hugo's jsonify returns template.HTML. Inside a
<script type="application/ld+json"> block, html/template JSON-encodes
that result again, so every value in the HowTo, TechArticle, and
LearningResource schemas rendered with literal quotes, for example
"name":"\"Chainguard OS on Raspberry Pi\"".

Drop jsonify and let html/template do the encoding, as
structured-data.html already does. This fixes 40 HowTo, 8 TechArticle,
and 12 LearningResource pages. The FAQPage and SoftwareApplication
blocks had the same pattern but match no pages today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthewhelmke
matthewhelmke requested a review from a team as a code owner October 16, 2026 14:05
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
chainguard-docs-preview Ready Ready Preview Oct 16, 2026 2:05pm UTC

Request Review

@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ornate-narwhal-088216 ready!

Name Link
🔨 Latest commit e5a0bba
🔍 Latest deploy log https://app.netlify.com/projects/ornate-narwhal-088216/deploys/6ad22f2de61e3b16089d7d05
😎 Deploy Preview https://deploy-preview-4229--ornate-narwhal-088216.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@matthewhelmke
matthewhelmke merged commit bddcc4a into main Oct 16, 2026
15 checks passed
@matthewhelmke
matthewhelmke deleted the fix-learning-lab-jsonld branch October 16, 2026 14:08

This branch was successfully deployed

1 active deployment
Preview — e5a0bbaf Deployed Oct 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant