Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

liquid - How to adjust Jekyll post order?

I have started a Jekyll based blog with a theme jekyll-now. I am new to Jekyll and how it operates (especially Liquid). I understand that new posts need to be as follows: 2014-10-04-Hello-World.md. But I really don't understand how I could order these.

My first thought is that they order by date so two posts on the same date would order randomly. But is this not the case? Is there a way of ordering posts chronologically. OR at least having a post archive page?

question from:https://stackoverflow.com/questions/26196559/how-to-adjust-jekyll-post-order

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is an example in the official Jekyll documentation how to create a basic post archive page:
Displaying an index of posts

Bonus: For a prettier archive page (grouped by year or year/month), see this answer.


You're right, I can't find anything in the docs where it says how the posts are ordered, but in fact Jekyll does order them chronologically, with the most recent post first (you can see this if you try the examples I linked above).

To sort them the other way (the oldest post first), you can use the reversed keyword, according to the Liquid documentation:

{% for post in site.posts reversed %}

However, I don't know how two posts on the same date are ordered, because I don't write that much posts, so I never had that problem :-)
You have to try that yourself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...