4

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
K3rn3l5
  • 351
  • 4
  • 18
  • Do you have files in your `_posts` directory? – Ross Allen Mar 20 '15 at 21:20
  • Also make sure your [post filenames](http://jekyllrb.com/docs/posts/#the-posts-folder) follow the `YEAR-MONTH-DAY-title.MARKUP` convention. – Ross Allen Mar 20 '15 at 21:21
  • Yup, already have both done. – K3rn3l5 Mar 20 '15 at 21:22
  • Did you add a paginate path in your config? `paginate_path: "/blog/page:num/"` – Ross Allen Mar 20 '15 at 21:34
  • `paginate_path` is mentioned in docs on enabling pagination: http://jekyllrb.com/docs/pagination/#enable-pagination – Ross Allen Mar 20 '15 at 21:35
  • Send your code to github. Give us the repository url and we'll give you a good answer in five minutes. – David Jacquel Mar 20 '15 at 21:58
  • I feel it might be due to the dir structure I have setup.. here is what I have `$ ls` `_config.yml _layouts _site css index.html` `_includes _posts blog img js` The ` index.html ` is a landing page, under the blog dir I have a index.md where I am trying to paginate the list of blog post (just a list not display or preview) – K3rn3l5 Mar 20 '15 at 22:20

1 Answers1

16

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...

astark
  • 609
  • 4
  • 7