今天才发现,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 --> 即可。

相关文章:

  • 2022-02-12
  • 2021-07-04
  • 2021-06-20
  • 2022-12-23
  • 2021-08-07
  • 2021-10-13
  • 2021-12-16
猜你喜欢
  • 2021-06-07
  • 2022-02-04
  • 2021-12-02
  • 2021-09-20
  • 2021-12-28
  • 2021-07-13
相关资源
相似解决方案