Jekyll分页 [英] Jekyll paginate

查看:245
本文介绍了Jekyll分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在jekyll中对博客文章列表进行分页,但似乎无法使其正常工作.这是我的设置 我的根目录下有一个博客目录,其中有一个index.md.我使用了jekyll网站上的以下代码

I am trying to paginate a list of blog posts in jekyll, but cant seem to get it working. Here's my setup I have a blog directory under my root directory which has a index.md. I have used the following code from the jekyll website

<ul>
{% for post in paginator.posts %}
<li><h1><a href="{{ post.url }}">{{ post.title }}</a></h1></li>
{% endfor %}
</ul>

我的_config.yml中有以下内容

I have the following in my _config.yml

paginate: 10

什么都没有显示.关于我要搞砸的地方有什么建议吗?

nothing get's displayed. Any suggestions as to where I am messing up?

更新-目录结构

$ls
_config.yml _layouts    _site       css     index.html
_includes   _posts

$ cd blog
$ ls
index.md

推荐答案

简单解决方案:如 jekyll docs中所述您必须提供index.html(即使blog.html也无法使用).

Simple solution: As written in the jekyll docs you have to provide a index.html (even blog.html won't work).

因此只需将blog/index.md更改为blog/index.html,并在_config.yml中设置paginate_path: "/blog/page:num/"paginate: 10,就可以了.

So simply change your blog/index.md to blog/index.html and having paginate_path: "/blog/page:num/" and paginate: 10 set in your _config.yml you are fine.

干杯...

这篇关于Jekyll分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆