How do I avoid the blank lines in the generated html?

Hi,

I noticed 2 things in my localhost site that hugo generated.

  1. Inline html comments are not being shown, and are being replaced with a blank line.
  2. Any line that has the hugo template code, ex {{ range... }} is also being replaced with a blank line.

So,

  1. How do I let the html comments stay in the generated code?
  2. How do I avoid these blank lines that are showing up where the hugo template code is present?

I noticed that the code generated in spf13.com doesn’t have any blank lines… so this must be possible.
Ex page: Do a view-source on http://spf13.com/presentation/the-future-of-the-os-linuxcon-2015-keynote/

Hello @shiva,

Go’s template language strips HTML comments as a safety feature.

You can show them in Hugo with the following syntax:

{{ "<!-- foo bar -->" | safeHTML }}

Remember that you have to do this with every HTML comments.


Go 1.6 enhanced the syntax of the template code. By adding dashes to the code blocks {{ }} you can remove the added whitespace. Look here for more information.

The next version of Hugo will be compiled with Go 1.6. Therefore, you will be able to use this feature in the next release.

Awesome. Thanks for the detailed reply @digitalcraftsman !.

For now, I will either use safeHTML in places where I need to see it (mostly for debugging, so I think this is fine).