今天突然想给每个 Category 下面的文章列表加个日期方便 review

如果直接使用

post.date

输出的日期格式为

2013-11-29 00:00:00 -0500

精确到秒也真的毫无必要,因此随手搜了一下相关 Solution1(实际使用时删掉下面代码中的星号)

To produce dates formatted like:

9 September 2013

Use this output filter:

{ { page.da*te | date: "%-d %B %Y" }}

The use of the dash (-) in the day location (%-d) prevents leading zeros in numbers below ten. Details on the individual date formatting tokens can be found on the Liquid "Output tags and filters" documentation page.

对应的显示效果

另外也可以参考这篇 post2

官方 API 打不开是什么鬼

参考文献

Footnotes

  1. how-does-jekyll-date-formatting-work

  2. jekyll-liquid-date-formatting-examples