How to create News pages grouped and sorted by date?

Hi,

I am new to the Jekyll. I want to create news pagination sorted by date as shown in picture.

  • Each page will have the news from only that year, sorted in descending order.
  • On the news page, directly underneath “News” is the year for the current page of news items
  • At bottom of the page, if you click next page, it should navigate to the previous year news.

I would really appreciate your help. Thanks.

jekyll won’t do this for you, but you could manually do it by making a page for each year and then filtering the posts for that year. Every january 1st you would need to add the next years page to everything though, so it would be a little painful to maintain over time.

You might look at the gem for GitHub - jekyll/jekyll-archives: 📚 Archive pages for your Jekyll tags and categories.

and see if that can do some of what you want (I haven’t used it).

I believe you’ll need to do all this manually. jekyll-archives is used in a template site to handle grouping blog posts by year, tag, or category (just click on the field on the demo). But apparently jekyll-archives only handle blog posts, not other collections.

So I believe you’ll need to first do a Group By Expression (check the docs) on your news collection to split it by year, then manually generate the year pagination. If inside a year page you also want to have pagination, I’d recommend using jekyll-paginate-v2 internally.