使用Jekyll官方的ReadMore摘要功能

今天才发现,Jekyll官方就支持ReadMore摘要功能,记录一下。

我之前的方法,在index.html中

{{ post.content ||split:'<!-- more -->' | first }}

然后在Post里,需要分隔的摘要后面加<!-- more -->。

摘要内容...
<!-- more -->
正文内容...

官方做法: excerpt

官方的方法是,在_config.yml里,指定摘要的分隔符:

excerpt_separator:  '<!-- more -->'

然后,在index.html中:

{{ post.excerpt }}

一般情况下,摘要需要去掉html标签,所以一般这样用:

{{ post.excerpt | strip_html }}

然后,和前一种方法一样,在摘要后面加<!-- more --> 即可。

posted @ 2015-08-15 21:39  CoderZh  阅读(2152)  评论(0编辑  收藏  举报