Date based pagination (one list page per day)

Following on from an issue I raised I was asked to post here about the ability to have date-based pagination.

I saw that Pagination and group by date did most of what I wanted, but I was still unable to get it quite working as I hoped.

I was hoping that I could have something similar to:

/ -> posts from today
/page/2/ -> posts from yesterday
/page/3/ -> posts from the day before yesterday

Using the following:

{{ $pages := (where .Site.RegularPages "Section" "not in" .Site.Params.IgnoreInFeeds).GroupByDate "02 January 2006" }}

<pre>
{{ (.Paginate $pages).Pages }}
{{ (.Paginate $pages).PageGroups }}
</pre>

We get:

Pages(0)
[Pages(9) Pages(16)]

However, it would be great if this was possible to only have one day’s content per page. Is this possible?

1 Like

check the samples

I would change it to

.GroupByDate "2006-01-02" "desc"

Although that does sort them, I still seem to see the issue that it’s not allowing pagination:

{{ $pages := (where .Site.RegularPages "Section" "not in" .Site.Params.IgnoreInFeeds).GroupByDate "02 January 2006" "desc" }}

<pre>
{{ (.Paginate $pages).Pages }}
{{ (.Paginate $pages).PageGroups }}
</pre>
Pages(0)
[Pages(14) Pages(11)]

Were you able to do what you wanted? I’m interested in exactly this, and can’t seem to figure it out either.

Unfortunately not - I’d be very happy if someone were able to help / if it was found that it needed changes to Hugo to make it work :+1:

This post doesn’t do quite what you’re asking for, but sure has a lot of the mechanics required to get there.