Repository navigation
Fix double-encoded values in enhanced JSON-LD - #4229
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for ornate-narwhal-088216 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
This PR removes
jsonifyfromlayouts/partials/head/enhanced-structured-data.htmland lets Go's html/template encode the values, asstructured-data.htmlalready does. Hugo'sjsonifyreturnstemplate.HTML, and inside a<script type="application/ld+json">block html/template JSON-encodes that result a second time.Affected pages
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
mainand this branch withhugo --gc --minifyand compared the output:json.loads, and none has a value wrapped in quotes. Onmain, 60 did.main's values decoded once more. The content is unchanged; only the extra encoding is gone.\/escaping.ai-metadata.json,ai-sitemap.json,concepts.json, andllms-full.txt, and thepolicy-controllertag title, which flips betweenPolicy-ControllerandPolicy Controllerfrom build to build because content uses both spellings.I didn't use
printf "%q" | safeJS.safeJSturns off the escaping that keeps a</script>in a title from closing the block, and%qcan emit Go escapes such as\x01, which aren't valid JSON.🤖 Generated with Claude Code