Jekyll Pagination无法正常工作

时间:2013-12-29 19:09:51

标签: html pagination jekyll liquid

我目前正在制作一个基于jekyll的主页,我不能让分页工作。

<ul class="posts">
    {% for post in paginator.posts %}
        <li>
            <span class="list_date">{{ post.date | date_to_string }}</span> &raquo; <span class="list_title"> {{ post.title }} </span><br>
            <span class="list_content">{{ post.content | strip_html | truncatewords:35}}</span> 
            <a href="{{ post.url }}">more...</a>
        </li>
    {% endfor %}
</ul>

这是我的流动代码,当使用网站而不是分页符时,它运行得非常好。 同样在我的_config.yml中我有这个部分:

paginate: 2
paginator_path: "news/page:num"

由于index.html文件位于新闻文件夹

3 个答案:

答案 0 :(得分:48)

Jekyll中的分页仅适用于index.html文件。 如果项目文件夹的根目录中有其他页面(例如,about.html,poems.html),则分页将不起作用。

要让分页工作在index.html以外的其他页面中,请为该页面创建一个新文件夹(例如诗歌/),然后将“poems.html”更改为“poems / index.html”。之后,_config.yml中的“paginate_path”应为'paginate_path:'poems / page:num /"'.

我还在调查这个问题。我的网站需要在多个页面上分页...... Jekyll似乎不支持开箱即用的东西

答案 1 :(得分:10)

我在使用Jekyll时遇到了类似的问题--watch自动加载功能。我的问题是配置没有自动更新。

手动重启Jekyll后,_config.yml中关于分页的新配置已加载,并且分页器开始工作。

此外,您似乎声明 paginator_path ,而文档说明它应该被称为 paginate_path

答案 2 :(得分:0)

此问题已在jekyll-paginator的版本2中得到解决。现在,您可以在任何页面中使用分页器,只需运行gem install jekyll-paginate-v2 More here

相关问题