How can quickly find which IsSet value not set?

When I tried to upgrade my theme to support Hugo v0.146.0+ , the console output a message said that WARN calling IsSet with unsupported type "invalid" (<nil>) will always return false. . And I used find tools search on theme files then see so many isset used, I’m not sure wich one was tigger this warn happened.

How can I debug and fix it ?

Example

If your site configuration does not contain a map named “foo” under the “params” key, this code:

{{ isset site.Params.foo "bar" }}

Will emit this warning:

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

Hugo emits this warning because site.Params.foo is nil.

Action

Check the first argument of every isset call to make sure it isn’t nil.

Notes

I’ve seen a lot of older sites and themes that use isset extensively when they should be using if, with, or range conditional blocks. See docs.

Thanks .
Indeed, I have read the official documentation and discussed the isset function in the forum. It seems that I need to rethink how to use the isset function more reasonably in the theme development.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.