Error: panic in Execute, with if statment

Hi :slight_smile:,

I’m new to Hugo and I have an issue, when I runserver my if statement throws the following error.

Error: Error building site: failed to render pages: render of "taxonomyTerm" failed: "C:\projects\travel-log\themes\travel-log\layouts\_default\list.html:1:1": execute of template failed: panic in Execute: runtime error: invalid memory address or nil pointer dereference. See "" for the reason why we cannot provide a better error message for this.

If I remove my if statement, my webserver start. Then if I add back my if statement, I don’t have any error and the code does what I expect :thinking:. I’m running Hugo v0.51 on Windows 10.

Not really sure what I’m doing wrong. Basically, I try to list out all the descendant posts from my list page.

{{ $thisPage := .CurrentSection }}
{{ range .Site.RegularPages }}
  {{ if .IsDescendant $thisPage}}
      <a href="{{ .URL }}">{{ .Title }}</a>
  {{ end }}
{{ end }}

Code is in the rebuild branch of this repo

Thanks for the help


I’m guessing it errors out because, without having their own layouts, taxonomyTerm pages also use that list.html layout.


Doing some testing, CurrentSection returns <nil> on taxonomyTerm and taxonomy pages , which explains the nil pointer error.

Thanks a lot :slight_smile:

As I do not need taxonomyTerm in my project I just disabled this option by adding this in my config.toml file:

disableKinds = ["taxonomy","taxonomyTerm"]