Yesterday, I took down my entire production site with a single character.
I was writing a new financial article titled “The 100k Illusion”. I wanted to be punchy, so I added quotes to the title. I committed the file, pushed to GitHub, and waited for the green checkmark.
Instead, I got this:
ERROR error building site: failed to process "/wealth/marginal-vs-effective/index.html":
expected comma character or an array or object ending on line 70 and column 40
The build failed. The site didn’t update. And the error message was pointing to a line of code that didn’t exist in my markdown file.
The Root Cause: “Naive” JSON Construction
The issue wasn’t in my article; it was in the theme.
I use PaperMod, a fantastic, fast Hugo theme. However, its method for generating SEO metadata (Schema.org JSON) was manually constructing strings.
It looked something like this:
"name": "{{ .Title }}",
If my title is , the output is valid JSON:
"name": "The 100k Illusion",
But if my title is (with quotes), the output becomes:
"name": ""The 100k Illusion"",
That is invalid syntax. The first quote closes the string, and the computer doesn’t know what to do with the rest.
The Fix: Let Hugo Handle It
The solution is to stop manually building JSON strings and let Hugo’s built-in function handle the heavy lifting. This function automatically escapes quotes and special characters so they don’t break the code.
I replaced the manual template code with this:
"name": {{ .Title | jsonify }},
"description": {{ .Description | plainify | jsonify }},
Now, no matter what characters I put in my title—quotes, dollar signs, emojis—Hugo converts them into safe, valid machine code.
The Lesson
- Don’t trust default themes blindly. Even popular open-source projects have edge cases.
- Read the logs. The error told me exactly where it broke (Line 70), even if it didn’t tell me why.
- Sanitize your inputs. In code (and in finance), you always have to account for the unexpected variable.
Now, back to the money.
