Today, I worked on a theme for my Blog and optimized some meta and title information on the various Pages. The current theme of this Blog inspired part of my new custom Hugo Theme.
The Pagination takes care of splitting the posts into different pages, but there is one crucial caveat you have to understand.
If you call .Paginator or .Paginate multiple times on the same page, you should ensure all the calls are identical. Once either .Paginator or .Paginate is called while generating a page, its result is cached, and any subsequent similar call will reuse the cached result. This means that any such calls which do not match the first one will not behave as written.
Like all the tech people, I would never read documentation for something as simple as a Paginator, right? But that was my downfall.
Due to a lack of understanding of the features, I had many calls to the .Paginator, but not all were filtered in the same way.
This was the most basic one.
|
|
Others first applied some filtering, before using the .Paginator object itself.
|
|
What in the end then matters is the order in which you call them. Before the first call to the .Paginator happens, you need to apply all the filtering through the .Paginate call. If you don’t do that and first use directly the .Paginator, then all parameters you pass to .Paginate later on, are ignored.
Lesson learned :)