Pagination

Aoife supports pagination for posts in the root folder, posts within sections and within archive lists. Whether or not pagination is required for a particular section depends on the postsPerPage variables in the site’s config.json file. For instance, suppose we have a blog with the following structure:

content
- Post 1.md
- Post 2.md
- Post 3.md
- Post 4.md
- Post 5.md
- Post 6.md

Aoife will automatically create an index list page (because we have not specified a static homepage) at /public/index.html using the rendering information in the list.html template file of the current theme.

If we leave postsPerPage at the default value (10) then Aoife will not need to paginate the index because we only have 6 posts. If however we change postsPerPage to 3 then Aoife will not only create public/index.html (which will list the first three posts: Post 1.md, Post 2.md and Post 3.md) but it will also create a second page at public/page/2/index.html (which will list the last three posts: Post 4.md, Post 5.md and Post 6.md).

Aoife provides convenient tags to output the URLs of the previous and next pages. These tags are {{nextPage} } and {{prevPage} }. These tags are only valid in list.html and archives.html template files.

Example usage

Here’s how I use these tags in my personal blog, which is built with Aoife:

<div class="list-navigation">
  <a class="prev-page" href="{{prevPage} }">← Previous</a>
  <a class="next-page" href="{{nextPage} }">Next →</a>
</div><!--/.list-navigation-->

Which would render something like this (assuming we’re on page 2 of the list):

<div class="list-navigation">
  <a class="prev-page" href="http://example.com/index.html">← Previous</a>
  <a class="next-page" href="http://example.com/page/3/index.html">Next →</a>
</div><!--/.list-navigation-->

Modified: Dec 9, 2016 at 00:12:58

Aoife v0.9.0 documentation