如何调整Jekyll的订单量? [英] How to adjust Jekyll post order?

查看:59
本文介绍了如何调整Jekyll的订单量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个基于Jekyll的博客,主题为 jekyll-now .我对Jekyll及其运作方式(尤其是Liquid)是陌生的.我了解新的帖子需要如下:2014-10-04-Hello-World.md.但是我真的不明白如何订购这些.

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?

推荐答案

Jekyll官方文档中有一个示例如何创建基本的帖子存档页面:
显示帖子索引

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.

您是对的,我在文档中找不到任何说明帖子排序方式的信息,但实际上Jekyll 确实按时间顺序对其进行排序,最新的帖子优先(您可以如果您尝试我上面链接的示例,可以看到此信息.

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.

这篇关于如何调整Jekyll的订单量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆