Pagination

This wiki describes several ways to get the next/previous page. However, if you are looking for a way to only display a specific set of posts or want to display X posts per page, then you can check out the Phile Paginator plugin.

Let's assume you content folder looks like this:

content/
|-- 404.md
|-- blog
|   |-- 1.md
|   `-- 2.md
|-- index.md
|-- projects
    |-- 1.md
    `-- 2.md

and you want a navigation in the blog pages. First you should group all pages by subfolder and sort by date (a usual meta-tag for blog pages): in your config.php set

$config['pages_order']  = 'page.folder:asc meta.date:asc meta.title:desc';

Then use in your twig template for the blog pages:

{% for page in pages %}
    {% if current_page.title == page.title %}
        {% if page.previousPage is defined and page.previousPage.folder == "blog" %}
            <a href="{{ page.previousPage.url }}"> Previous </a>
        {% endif %}

        {% if page.nextPage is defined and page.nextPage.folder == "blog" %}
            <a href="{{ page.nextPage.url }}"> Next </a>
        {% endif %}
    {% endif %}
{% endfor %}

Edit the source page on github…