我期待在索引页上显示较长文章或摘要页的短文摘要。我本来打算在接待物质使用自定义变量,抓住,后来我看到了.excerpt
如何在Jekyll中使用markdownify在索引上显示摘录
我在Jekyll docs看到有{{ page.excerpt | markdownify }}
东西叫我怎么会标记降价页面或文章,以便在过滤器使用该过滤器?
编辑:或者markdownify获取整个.md文件?
我期待在索引页上显示较长文章或摘要页的短文摘要。我本来打算在接待物质使用自定义变量,抓住,后来我看到了.excerpt
如何在Jekyll中使用markdownify在索引上显示摘录
我在Jekyll docs看到有{{ page.excerpt | markdownify }}
东西叫我怎么会标记降价页面或文章,以便在过滤器使用该过滤器?
编辑:或者markdownify获取整个.md文件?
在您需要先设置您的摘录后降价文件,这里是我的信息的一个例子
layout: post
title: A developers toolkit
date: Friday 14 December, 2012
excerpt: What text editor to use? Sass or plain old CSS? What on earth is Compass? Command line? I'm not touching that. Sound like you? Welcome, I was once like you and this is the guide I wish someone had given me.
然后索引页上所说的标签
{{ post.excerpt }}
这应该然后输出您在降价文件中写下的内容。好,简单,为什么我爱杰基尔。
Jekyll有一个选项excerpt_separator
,它适合你。 事情是这样的:
在_config.yml
:
excerpt_separator: <!--more--> # you can specify your own separator, of course.
在你后:
---
layout: post
title: Foo
---
This appears in your `index.html`
This appears, too.
<!--more-->
This doesn't appear. It is separated.
注意您必须准确键入<!--more-->
,不<!--More-->
或<!-- more -->
。
在你index.html
:
<!-- Loop in you posts -->
{% for post in site.posts %}
<!-- Here's the header -->
<header>
<h2 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h2>
</header>
<!-- Your post's summary goes here -->
<article>{{ post.excerpt }}</article>
{% endfor %}
输出是这样的:
<header>
<h2 class="title"><a href="Your post URL">Foo</a></h2>
</header>
<article>
This appears in your `index.html`
This appears, too.
</article>
作为参考84cfc1cef
的jekyll GitHub的版本支持每帖excerpt_separator
所以你必须添加引用到Gemfile:
gem 'jekyll', github: 'jekyll/jekyll', ref: '84cfc1ceff0474fd3eb3beb193ae59ae43694863'
和创建具有以下YAML
柱:
---
title: Post Excerpt Separator
excerpt_separator: "\n---\n"
---
不工作为亩,或集合,击中除了解析液体时化身恐慌。我不知道这是为什么,它应该按照你的建议工作。
还存在另一种:
post.content或我的情况是:blogX.content并通过一些文字过滤器,限制内容的大小粉碎它。
ie: {{blog.content | strip_html | truncatewords:100}}
@kaplan这是更合适的答案。它应该被接受。 – kleinfreund 2014-01-19 16:15:22
@kleinfreund事实上,我在接受第一个答案几个月后回答了这个问题。 – 2014-01-21 02:18:21
我知道。这就是我评论的原因。这是更合适的答案。 – kleinfreund 2014-01-21 09:18:19