Check for "not isset"

I am trying to find out if a front matter variable is NOT set in a template. Strangely I always thought I could use something like ne isset to do this, but the following code results in an error:

{{ if ne (isset .Params.HideMeta) }}

I would expect the if to hit if the current post has not set hideMeta in it’s front matter. It doesn’t, the error is:

ERROR 2019/02/04 21:56:42 Failed to render pages: render of "home" failed: "/path/layouts/_default/list.html:11:12": execute of template failed: template: _default/list.html:11:12: executing "main" at <ne>: wrong number of args for ne: want 2 got 1

trying

{{ if ne (isset .Params.HideMeta) true }}

brings the same error, this time for isset.

After much testing I end up using

{{ if ne (isset .Params.HideMeta "true") true }}

Which doesn’t work either, warning me with

WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false.
WARNING: calling IsSet with unsupported type "bool" (bool) will always return false.

How should I test, if a front matter variable exists? And why is there no easy way to negate an isset test, like !isset in other script languages?

(sidenote: I have posts and pages. posts and the homepage (list) shall show meta data for the entry (like date, author), but pages should show only title and content. which is why I want to check if a certain front matter is set.)

Try it with with

{{ with .Params.HideMeta }}
true
{{ else }}
false
{{ end }}

Yep. That does the trick, thanks :slight_smile: