Read paginate site configuration

In the site configuration it is possible to set the paginate field to set the pagination chunk size as documented on Pagination | Hugo.

What I however do not find any documentation or thread about is how to get this value in a template. I.e. I want to do something along the lines of

{{ if (gt .Site.paginate 5) }}
# some html
{{ end }}

to conditionally display something if the paginate configuration is greater than 5.

I understand that the above snipped does not work since paginate is not part of the site variables but is there any other way to access the field?

My workaround so far is to duplicate the paginate field under params and access it through .Site.Params.paginate but it would be nice if that was not needed.

You are looking for .Pagination.Pagenumber. Depending on your template the .Pagination can have a different variable name. This is of course only available after you created the pagination object.

It is similar but .Pagination.Pagenumber I think gives the number of the page in the sequence, not the number of pages that are displayed at the same time which paginate configures.

But I think it might not be possible if this post from 2018 still is true Retrieve/test site global config. So this might be a duplicate if nothing has changed since then.

But thanks for the reponse!

1 Like



Thank you very much, that was as good as it gets.

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