Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll Paginator not working

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

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

like image 850
Heho Avatar asked Dec 29 '13 19:12

Heho


People also ask

What is pagination Jekyll?

With many websites — especially blogs — it's very common to break the main listing of posts up into smaller lists and display them over multiple pages. Jekyll offers a pagination plugin, so you can automatically generate the appropriate files and folders you need for paginated listings.


1 Answers

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

like image 144
wsgeorge Avatar answered Sep 20 '22 13:09

wsgeorge