Jekyll Paginator not working

Viewed 7915

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

4 Answers

My few cents to @wsgeorge answer. Assuming that you installed jekyll-paginate not jekyll-paginate-v2

  1. Remember to rename index.md to index.html

  2. Add paginate: true to index.html

    ---
    layout: home
    paginate: true
    ---
    
  3. 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).

Related