Why do I need an {{ if .Type }} to avoid crashing?

Why is the outer “if” required?

{{if .Type}}{{if eq .Type "pan"}}panzoom{{end}}{{end}}...

If I don’t include it, and .Type is not available, hugo stops evaluating this partial without any error, and the “…” from the end is missing (in my case, all the html was broken). In other languages one can compare null or undefined with a string without breaking the program, so I wonder what goes on in this case.

Would it be possible to display some debugging information when this happens?

A second question is, is there a shorter way of writing the “double if” construction?

Ok now I see the “double if” does not help.

The problem is there with pages that are a list of items (blog posts, etc). Single pages (like about) work fine. Why could that be?

Update: I’ve found a way to avoid crashing it:

{{if not .IsNode}}{{if eq .Type "pan"}}panzoom{{end}}{{end}}

Still, it would be good to know how we should debug such an issue and why it’s happening.

Look at Example 3: and & or and Example 4: with on http://gohugo.io/templates/go-templates/ for an example of how to work around the “double if” that you have.