No changes to code: runtime error: invalid memory address or nil pointer dereference

I appreciate this will be a difficult question to help with as I can’t share my project, but any pointers would be much appreciated.

I added two new content files this morning to my project and now I get the error message: “runtime error: invalid memory address or nil pointer dereference”. I revert to the last build that succeeded and now that also gets the same error message.


3 hours later, and I’ve managed to figure this out. One of my custom parameters in front matter was misspelled, “pproduct” instead of “product” for a file that was committed a few days ago (hence no error yesterday) but was scheduled to be published today. An error on my part.

It would be awesome, but I appreciate this is difficult and perhaps not possible, to have more descriptive error messages.

You can use Hugo’s errorf to create your own error messages.

{{ if not (isset .Params "product") }}
  {{ errorf "Page %s does not have Params.product set." .Path }}
{{ end }}
1 Like

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