Running Hugo Static Site Generator v0.36.1 linux/amd64 BuildDate: 2018-02-15T09:07:45Z
Hi
According to the docs, HTML comments are stripped from the output by the go template engine. This works as expected.
However, it appears the comments are still rendered before being stripped. I consider this is a bug because this behaviour is not documented, can produce errors but cannot produce any useful result that I could see.
How to reproduce the issue:
<-- {{ partial "test.html" }} -->
Then in partials/test.html:
--> Will this appear?
The result is nothing appears. Please note that in the example provided I tried to close the comment markup in the partial template, to ensure nothing would show up in this arcane setup.
But for example, calling a non-existing template from a comment will raise a build error:
executing "theme/partials/footer.html" at <partial "LOL.html">: error calling partial: Partial "LOL.html" not found
Why do I feel like this is a bug?
As what’s inside the HTML comments never produces anything in the end, I don’t think it should bother to try and render the content. In my opinion, HTML comments should be treated like go templates comments unless specifically told otherwise.
I stumbled upon the issue because I was using HTML comments to comment my templates. I didn’t know about go templates comments before I actually rtfm. I feel like whatever decision you take in regards to this issue, the documentation should be clearer about this behaviour and how to properly comment templates. I will make a pull request when I find an hour
Also, I realized this may be a “bug” on go template’s side and that’s why I didn’t directly submit an issue on Github.
Thank you for maintaining Hugo, it’s a pleasure to build websites with <3