If you're just learning Hugo like me, you may want to start with Go's template documentation. The conditional sytax tripped me up for a minute. If you're accustomed to writing conditionals like this:

if ($x == $y)
if ($x && $y)
if ($x == $y || $x == $z)

This is how it would look in a Go template:

{{ if eq $x $y }}
{{ if and $x $y }}
{{ if or (eq $x $y) (eq $x $z) }}

In a Go template, eq is a function that you pass arguments to, not a comparison operator like you would use in JavaScript.

Aug 30, 2017 @ 12:30pm
  • Code