How to check if variable is a negative number

Hello! I’m looking for a way to do this:

{{ if $increment > 0 }}
    There was an increase
{{ else }}
     There was a decrease
{{ end }}

If a variable is greater than 0 then show a message. Else show a different message.

Thanks for your help!

{{ if gt $increment 0 }}

Thanks! That’s exactly what I needed.
I didn’t find that gt function.

You’re correct about the docs. We’ll get it fixed.

https://github.com/gohugoio/hugoDocs/issues/91

3 Likes