Jekyll-Improved-Paginator-Plugin

Jekyll-Improved-Paginator-Plugin

Jekyll's built-in paginator is incredibly limited. This looks to do more.

Jekyll-Improved-Paginator-Plugin

Jekyll's built-in paginator sucks! You are forced to use index.html to paginate only posts, for reasons I don't understand, and you have to work-around with what I feel is too much restriction; so this repo contains a plugin that fixes that, or attempts to (would be great to contrib to mainline). You can list a specific collection, or all posts, and pagination works seamlessly supporting some edge use-cases I felt the paginator did not address.

Usage:

  1. download the _plugins/listing_pages.rb and place in your _plugins folder

  2. In the page(s) you wish to use include the relevant frontmatter (changing as required) list_for: posts list_limit: 2

  3. Include the relevant liquid to list your objects

    ```liquid

    {% if page.pages >= 1 %}
      Page {{ page.curpage }} of {{ page.pages }}, {{ page.list_for }} {{ page.min_rec }} to {{ page.max_rec }} {% for item in page.list %}
    • {{ item.title }}

      {{ item.excerpt }} More...
    • {% endfor %}
    {% endif %} {% if page.pages > 1 %} {% capture nextpg %}{{ page.curpage | to_i | plus: 1 }}{% endcapture %} {% capture prevpg %}{{ page.curpage | to_i | minus: 1 }}{% endcapture %} {% endif %}
```
  1. Save the file and restart Jekyll.

N.b.: If you specify a list_for that does not exist, or is invalid, this will error. As the intended use-case for this is to be staged to a site this is fine for production, however do not put this inside a Jekyll generator online, as if you screw up the front-matter your site may experience downtime.

Todo:

  • Work on alternative sorting option per-page
  • Work on supporting listing anything Jekyll can access (files, collections, pages, posts)
  • Work on filtering what Jekyll is looking for
  • Work on liquid for last and first page numbers
  • Work on nicer liquid for framed 5 page numbers only relative to current number + or - 2 [1,2,3,4,5] page 1, 2 & 3 [2,3,4,5,6] page 4 [95,96,97,98,99] page 99
  • Work on extending to work with data files to generate listings
jekyll logo

Want a Jekyll website built?

Hire a Jekyll developer