I have a website with about 4000 posts that I use with the PaperMode theme. To avoid having to regenerate the entire index page structure (with summarized posts) each time, I would like to try the following algorithm: the pages containing the most recent posts should have the highest index.
To be more explicit I give an example. I have 40 posts grouped in ten posts per page. In default mode, hugo generates on page 1 the 10 most recent posts, on page 2, the next 10 oldest … on page 4 the 10 oldest posts.
If instead of doing that it would set page 1 with the oldest 10 posts, page 2 with the next 10 posts, and finally page 4 with the most recent 10 posts, it would not be necessary to regenerate all the pages each time. Page number 4 could remain to be generated until it reaches 19 posts, then, at the twentieth post, it would be split in two: page 5 with the 10 most recent posts and page 4 with the next 10 posts.
I am new to hugo and haven’t found a solution that works like this. Do you think it exists? It would be much more logical and it would save extremely processing time
Changing the sort order of a paginated list is trivial (sort the page collection prior to pagination), but it’s not going to reduce build times.
Pagination is very fast unless the code that renders the navigation UI does something silly (e.g., iterate over every pager on every pager), and the results are cached.
If you are experiencing long build times, pagination is almost certainly not the culprit.
Thanks for your answer. My problem is that every time I add a new post, all the pages containing the links to the articles are refreshed. This means that, for each post I have to update the server for about 400 pages, which seems useless to me, as the elegant solution would be to generate only 2 pages maximum
I don’t think you understand my proposed strategy: the pages containing the oldest posts will not be regenerated because nothing changes on them. The page with the 10 oldest posts will always have page number 1 and its previous page will be page 2. Page 2 will always have page 3 as the previous page and page 1 as the next page. In these already generated pages nothing will change. The only pages that would change would be either the page with the most recent 10-20 posts, or this page and the next one.
I hope I made myself clear.