【发布时间】:2023-03-13 03:05:02
【问题描述】:
我在 Jekyll 生成的网站上使用分页器时遇到了一个奇怪的行为。 我曾经将最后 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>
当我在 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 变为空。我尝试了标准行为和技巧。
_config.yml 中的构建设置如下:
# Build settings
gems: [jekyll-sitemap]
markdown: kramdown
highlighter: rouge
permalink: pretty
paginate: 5
paginate_path: "/archives/page/:num"
谢谢
【问题讨论】:
标签: pagination jekyll