Add comment on startpage

Hi!

In which file do I need to change if I want to add an html comment on the startpage of localhost:1313? I have tried list.html and single.html inside themes/hugo-theme-nix/layouts/_default. I have also tried index.html in themes/hugo-theme-nix/layouts.

Appreciate all help!

As you mentioned, themes/hugo-theme-nix/layouts/index.html would be one place for this.

But you would need to share your code to confirm this, since we can’t see your specific site structure.

I tried in that file, it has this code https://pastebin.com/cJauGxBH

But it doesn’t show up when I check source-code on localhost:1313.

Try adding the comment like this:

{{/* the comment */}}

Also, see the hugo docs on comments.


I see you want an HTML comment not a Template comment, so try this instead:

{{ "<!-- the comment -->" | safeHTML }}
1 Like

I tried: {{ /* something here */ }} but then I get error: /themes/hugo-theme-nix/layouts/index.html:10:1" : parse failed: template: index.html:10: unexpected “/” in command

If I do: {{ printf "<!-- comment here -->" }} , it prints the comment <!--comment--> but not in source-code but on actual page.

If I do: {{ <!-- comment here--> | safeHTML }} , I get: Error themes/hugo-theme-nix/layouts/index.html:10:1" : parse failed: template: index.html:10: unexpected “<” in command

I solved it now with quotes around it: {{ "<!-- comment here-->" | safeHTML }} . Thanks for the help!