Adding Previous and Next Post Navigation
In this post, I’ll show how to add links to a previous and next posts. This makes it easier to navigate between posts back and forth.
The final result looks like this:
The code for the previous and next post links can be found in the previous-next-post-links.html
include. The implementation looks like the following:
It uses page.next
and page.previous
variables to render links. If a next or previous post is not available, the value will be nil
.
The include is added to the post.html
layout, so these links will be rendered for every blog post.
CSS styles for links are defined in previous-next-post-links.scss
.