Cho*_*Ren 77
Jekyll有一个excerpt_separator适合你的选择.事情是这样的:
在_config.yml:
excerpt_separator: <!--more--> # you can specify your own separator, of course.
Run Code Online (Sandbox Code Playgroud)
在你发布:
---
layout: post
title: Foo
---
This appears in your `index.html`
This appears, too.
<!--more-->
This doesn't appear. It is separated.
Run Code Online (Sandbox Code Playgroud)
请注意,您必须准确输入<!--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 %}
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
<header>
<h2 class="title"><a href="Your post URL">Foo</a></h2>
</header>
<article>
This appears in your `index.html`
This appears, too.
</article>
Run Code Online (Sandbox Code Playgroud)
jos*_*y10 14
在post markdown文件中,您需要先设置摘录,以下是我的一篇帖子中的示例
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.
Run Code Online (Sandbox Code Playgroud)
然后在索引页面上调用标记
{{ post.excerpt }}
Run Code Online (Sandbox Code Playgroud)
然后应该输出你在markdown文件中写的内容.很好,很简单,为什么我喜欢Jekyll.
| 归档时间: |
|
| 查看次数: |
10417 次 |
| 最近记录: |