Skip to content

Hugo Basics


Built-in Functions


When you need to find out whether a particular value is inside a given string or a slice:



A particular example comes from my current effort to rebuild my blog in Hugo. Certain posts of mine contain the tag micropost and should be rendered differently from the rest. To find those out, I had to do the following:

{{ if in .Params.tags "micropost"}} 
  This is a micropost 
{{ end }}

Alternatively, to find the inverse of this, i.e. the posts that are not microposts, I had to use the ne2 function in a combination with in. it is a bit more cumbersome, but it works:

{{ if ne true (in .Params.tags "micropost")}}
  This is NOT a micropost
{{ end }}