I’m sure a lot of you are Hugo experts, but I wanted to share this article with you that I wrote that discusses Hugo’s approach to templating and conditionals. When discussing Hugo with non-Hugo devs I frequently hear complaints about how “crazy” the templating system is, when I think it is easy to understand and follows a simple ruleset. I hope this article helps clear some of that up.
Thanks for the article. This adds some clarity to conditional evaluation.
A question outside the scope of the article – I’m trying to understand when to use with vs if. I see them used interchangeably in several cases, yet with doesn’t work in this scenario:
{{ with .Resources.Match "itemName" }}
<h2>{{ .item-name-title }}</h2>
{{ end }}
will error out, yet
{{ if .Resources.Match "itemName" }}
<h2>{{ .item-name-title }}</h2>
{{ end }}
will evaluate successfully. What are the parameters to determine when if should be used instead of with?