Searched around here, but couldn’t find this problem.
Markdown in tmp.md:
<div></div>
<script>
function f(x) {
return x;
}
</script>
Config (unsafe rendering is enabled):
[markup.goldmark.renderer]
unsafe = true
Commands (minify is enabled):
❯ hugo version
hugo v0.163.3+extended+withdeploy darwin/arm64 BuildDate=2026-06-18T16:18:24Z VendorInfo=Homebrew
❯ hugo --baseURL https://example.com --minify
Output:
Start building sites …
hugo v0.163.3+extended+withdeploy darwin/arm64 BuildDate=2026-06-18T16:18:24Z VendorInfo=Homebrew
Total in 1006 ms
ERROR error building site: render: [en v1.0.0 guest] failed to render pages: failed to process "/tmp/index.html": "/var/folders/bx/qk0phsxd265fqj512dnnpg080000gp/T/hugo-transform-error1046853356:393:9": unexpected < in expression on line 393 and column 9
3: <p>return x;
^
If you delete the div, it works:
<script>
function f(x) {
return x;
}
</script>
If you put a blank line after the div, it works:
<div></div>
<script>
function f(x) {
return x;
}
</script>
If you delete the blank line after the function keyword, it works:
<div></div>
<script>
function f(x) {
return x;
}
</script>
Oddly, before doing any of those things (using the original code), the syntax highlighting for the JS is screwed up in the Helix text editor, rendering the JS as plain white text (perhaps as plaintext?). After doing any of those things, the syntax highlighting for the JS starts working.
The error only happens when --minify is used.
I’m scratching my head trying to understand what’s going on here. ChatGPT wasn’t helpful. At first I thought the issue was the JS being indented 4 spaces, but the error still happens without indentation.
This (HTML inside) Markdown code used to work with Hugo. I’m not sure when it stopped working.