[英]Jekyll paginator killed post.excerpt
I have got a bizarre behaviour using paginator on a Jekyll generated website. 在Jekyll生成的网站上使用分页器时,我有一种奇怪的行为。 I used to create the list of the last 3 posts as
我曾经创建了最近3个帖子的列表
<ul class="post-list">
{% for post in site.posts limit:3 %}
<li>
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
<h2>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
<p>{{ post.excerpt }}</p>
</li>
{% endfor %}
</ul>
As soon as I activated the paginator in Jekyll and cycled pages as 当我在Jekyll中激活分页器并将页面循环
{% for post in site.posts %}
<div class="post-preview">
<a href="{{ post.url | prepend: site.baseurl }}">
<h2 class="post-title">{{ post.title }}</h2>
{% if post.subtitle %}
<h3 class="post-subtitle">
{{ post.subtitle }}
</h3>
<p>{{ post.excerpt }}</p>
{% endif %}
</a>
<p class="post-meta">Posted by {% if post.author %}{{ post.author }}{% else %}{{ site.title }}{% endif %} on {{ post.date | date: "%B %-d, %Y" }}</p>
</div>
<hr>
{% endfor %}
post.excerpt
becomes empty. post.excerpt
变为空。 I tried both with the standard behaviour and with the trick. 我尝试了标准行为和技巧。
Build Settings in _config.yml are as such: _config.yml中的构建设置如下:
# Build settings
gems: [jekyll-sitemap]
markdown: kramdown
highlighter: rouge
permalink: pretty
paginate: 5
paginate_path: "/archives/page/:num"
Thank you 谢谢
You've put {{ post.excerpt }}
expression in a conditional statement. 您已将
{{ post.excerpt }}
表达式放入条件语句中。
{% if post.subtitle %}
<h3 class="post-subtitle">{{ post.subtitle }}</h3>
<p>{{ post.excerpt }}</p>
{% endif %}
So, no subtitle, no excerpt ! 所以,没有字幕,没有摘录!
This is better : 这个更好 :
{% if post.subtitle %}
<h3 class="post-subtitle">{{ post.subtitle }}</h3>
{% endif %}
<p>{{ post.excerpt }}</p>
In order to render paginated posts you must loop in paginator.posts
see documentation 为了呈现分页的帖子,您必须在
paginator.posts
循环查看文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.