hugo: --minify breaks on JSON since 59.0
Since 59.0 hugo throws errors when trying to minify JSON files.
Building sites … ERROR 2019/11/01 16:57:44 parse error:1:1: unexpected character
1: {"output":{"data":{"created":"2010-02-11T12:46:02Z","draf...
^
ERROR 2019/11/01 16:57:44 parse error:1:1: unexpected character
1: {"output":{"data":{"created":"2010-03-08T16:25:25Z","draf...
^
It appears the minify lib has been updated to v2.5.2
with Hugo 59.0 so wondered if that could trigger the issue… https://github.com/gohugoio/hugo/commit/b401858ebd346c433dd69a260eba7098bded5a30
I’ll try and share a repo later.
Thanks!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 26 (12 by maintainers)
Commits related to this issue
- minifiers: Add a JSON roundtrip test See #6472 — committed to gohugoio/hugo by bep 5 years ago
- temporarily remove minification due to https://github.com/gohugoio/hugo/issues/6472#issuecomment-559238453 — committed to roytang/blog by roytang 4 years ago
- エラーが出るので minify オプションを外してみる https://github.com/gohugoio/hugo/issues/6472 — committed to yukihane/yukihane.github.io by yukihane 3 years ago
- エラーが出るので minify オプションを外してみる https://github.com/gohugoio/hugo/issues/6472 — committed to yukihane/yukihane.github.io by yukihane 3 years ago
- エラーが出るので minify オプションを外してみる https://github.com/gohugoio/hugo/issues/6472 — committed to yukihane/yukihane.github.io by yukihane 3 years ago
here you go @anthonyfok : https://github.com/theNewDynamic/gohugo-6472
Thanks a lot for your patience.
I have fixed this problem partially in tdewolff/parse@2.3.14 (with tdewolff/minify@2.6.1). What remains is that Hugo parses a generated HTML document by a JSON parser.
This can be confirmed by adding:
before line 54 in
hugo/minifiers/minifiers.go
. It outputs:Stack trace:
Edit: Looks like
Page(/article/_index.md)
with output formatJSON
(and thus mediatypeapplication/json
) is send through thepages
channel inhugolib/site_render.go:127
while the content is clearly HTML. I’m not very familiar with the code base of Hugo, so I don’t know where this channel item is coming from. @anthonyfok any ideas?