4
votes

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>

I have the following in my _config.yml

paginate: 10

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

Update - Dir structure

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

$ cd blog
$ ls
index.md
1
Do you have files in your _posts directory? - Ross Allen
Also make sure your post filenames follow the YEAR-MONTH-DAY-title.MARKUP convention. - Ross Allen
Yup, already have both done. - K3rn3l5
Did you add a paginate path in your config? paginate_path: "/blog/page:num/" - Ross Allen
paginate_path is mentioned in docs on enabling pagination: jekyllrb.com/docs/pagination/#enable-pagination - Ross Allen

1 Answers

16
votes

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

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.

Cheers...