Comments in Hugo templates can be defined with (no whitespace trimming):
{{/* This is a comment. */}}
Or (with whitespace trimming):
{{- /* This is a comment. */ -}}
You can also combine these two:
{{/* This is a comment. */ -}}
{{- /* This is a comment. */}}
As with all Hugo template blocks, a hyphen (-
) trims all whitespace before or after the block.
These two variants are only supported ways. Note especially that neither {{ /*
nor */ }}
are valid (with a space).
You can also use HTML comments which basically function like {{/* ... */}}
(i.e. without whitespace trimming).