Is there a way to get page number outside Pagination?

Due to the issues mentioned here, can I get the current page number without .Paginate or .Paginator? I copied this implementation I stumbled upon when searching the forum to my index and section templates, so suggestions like this and this don’t work for my site. I am dreading getting penalized by Google search for an issue outside my control.

I don’t understand why you can’t use $.Paginator.PageNumber. It will exist while processing any paginated page, or you couldn’t have page numbering at all. Take a look at the built-in page-navigation template.

This might help clarify the problem:

https://discourse.gohugo.io/t/determine-if-current-page-is-result-of-pagination/37494/4

2 Likes

So for the time being there is no solution? (Coming from Jekyll to Hugo, I just noticed recently Hugo didn’t have /page/:number, but Jekyll does!)

Like I said, for the moment, I’ll take a zero.

In layman’s terms?

It means I don’t know of a solution to the problem. If I knew of one, I would have posted it.

1 Like

These are some issues I now think I will look at more closely while doing my other site conversions. Cheers for trying though.

@jgreely doing that breaks the implementation by @jmooring shared in the first link since pagination cannot be called twice in the same template.

I have spent hours on this issue on every implementation possible. Even moving {{ $paginator =: ... }} to baseof.html, but it didn’t work or throws errors.

Ah, that does explain it, because I built my template when Hugo 0.19 was current, and haven’t refactored it to use baseof-style.

The learning for me was made easier from cloning a test site from GitHub which explained these than the documentation. I don’t use a theme. I am a recent convert since version 0.89.

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