Nil pointer when using .eq and NextPage.params

As per title, I’m using some conditions to check if the next page has been set in a language or in another one. To check that, I have:

if eq .NextPage.Params.lang "en"

The problem is that I got the error of “nil pointer evaluating page.Page.Params”.

Any help?

NextPage will be nil when you arrive at the end. You need to first check if it’s not:

if .NextPage
if eq .NextPage.Params.lang "en"

Worked thanks. I’ll probably donate some buckets to gohugo! It’s really too amazing.

1 Like

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