Reputation: 339
I am currently working on a jekyll based homepage and I cant get pagination working.
<ul class="posts">
{% for post in paginator.posts %}
<li>
<span class="list_date">{{ post.date | date_to_string }}</span> » <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>
This is my liquid code and it works perfectly well when using site instead of paginator. Also in my _config.yml I have this part:
paginate: 2
paginator_path: "news/page:num"
Since the index.html file is in the news folder
Upvotes: 34
Views: 8957
Reputation: 13630
My few cents to @wsgeorge answer. Assuming that you installed jekyll-paginate not jekyll-paginate-v2
Remember to rename index.md
to index.html
Add paginate: true
to index.html
---
layout: home
paginate: true
---
Add following to _config.yaml
paginate: 5
paginate_path: ./page:num/
Notice: . (period) in ./page:num/
path - this indicates that my index.html
file is in the root directory (directory along/next to Gemfile).
Upvotes: 3
Reputation: 623
I encountered a similar problem using Jekyll with the --watch autoreload feature. My issue was that the configuration wasn't being updated automatically:
Auto regeneration is not working with _config.yml?
After restarting Jekyll manually, the new configuration in _config.yml regarding the pagination was loaded and the paginator started working.
Also you appear to be declaring paginator_path while the documentation states it should be called paginate_path.
Upvotes: 14
Reputation: 31
This problem has been fixed in version 2 of jekyll-paginator. Now you can use paginator in any page just run:
gem install jekyll-paginate-v2
Upvotes: 3
Reputation: 1968
Pagination in Jekyll only works in an index.html file. If you have other pages in the root of your project folder (say, about.html, poems.html) pagination will NOT work in them.
To have pagination work in another page other than your index.html, create a new folder for that page (say, poems/) and change what would have been "poems.html" to "poems/index.html". After that, your "paginate_path" in _config.yml should be 'paginate_path: "poems/page:num/"'.
I'm still investigating this issue. My site needs pagination on multiple pages...something which Jekyll doesn't seem to support out-of-the-box
Upvotes: 71