Difference between {{ keyword }} and {{- keyword -}}

I have been a long time user of Hugo for my personal website and blog.
I have learned bits of go-templating as and when I needed to learn more. So I lack a depth of understanding that someone who has been a go programmer or have used templates extensively in their career.
I have noticed that in the docs page, in certain parts of it, I see that the double curly braces are followed by a hyphen. Whereas in others they aren’t. I don’t even know what to search for, as this seems like a syntax question. I’m starting to create custom partials in my website and so this thought bothered me.

The double curlies work with or without the hyphen following it.

For example: Menus | Hugo page shows all double curlies followed by a - first.

Whereas in this Introduction to templating | Hugo page, the examples do not use the - after the double curlies!

Is there a meaningful difference? Or is this just a quirk of the go templating - something like the hyphen was necessary in earlier versions of go templates, but later, that was made optional?

https://gohugo.io/templates/introduction/#whitespace

1 Like

Thank you very much. That was lightning fast!
Thanks to you, I also learned: {{ and }} are the default delimiters. Didn’t know what to call them, either.
Marking your answer as the solution.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.