Another interesting case with Hugo If and Range not working as they should

I cannot reproduce your error. Please provide a link to the full source repo and commands you use, and version of Hugo and Go.

Also see: Requesting Help

EDIT: Here’s the test case

With the following shortcode:

{{with .Page }}
    {{ if eq 1 0 }}
        {{ range $p := where ( where .Params.does_not_exist "visible" true) "another" false }}
            {{ print $p }}
        {{ end }}
    {{ end }}
{{ end }}

and in a content page:

---
title: "Demo Post"
date: 2021-11-23T00:11:54-05:00
---

Just to make sure the site works

{{< false-if-but-where >}}

Which would exhibit the problem if the if weren’t working. It works for me, therefore there is something more than you are telling us.

Removing the {{ if eq 1 0 }} results in:

execute of template failed: template: shortcodes/false-if-but-where.html:2:31: executing "shortcodes/false-if-but-where.html" at <where .Params.does_not_exist "visible" true>: error calling where: can't iterate over <nil>