Add comment on startpage


#1

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!


#2

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.


#3

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.


#4

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 }}

#5

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 “” }} , it prints the comment but not in source-code but on actual page.

If I do: {{ | 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: {{ “” | safeHTML }} . Thanks for the help!