How to sort posts by modified date when using pagination?

248 Views Asked by At

I add a 'modified' date to my posts and make them sorted from new to old by modified date instead of posted date. Make people notice the update of posts.

I have ymal for posts , like this:

---
title: Mytitle
posted: 2020-06-29
modified: 2020-07-29
....

And the following code works well:

{% assign my_sorted_list = site.posts | sort:"modified" %}
{% for post in my_sorted_list %}
  ...
{% endfor %}

But when I turn on the jekyll-paginate in my _config.yml, it is sorted by the posted date again.

Is there any way I can sort by modified date when I turn on the pagination? I have tried a few methods but nothing seems to work. Please help!

1

There are 1 best solutions below

1
Cynthia On

I suppose this function is not supported. Because I found this pull request. This request aims to that paginator can sort posts by modified date. And this request is not merged yet.