rmaicle

Programming is an endless loop; it's either you break or exit.

Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA).
You are free to copy, reproduce, distribute, display, and make adaptations but you must provide proper attribution. Visit https://creativecommons.org/ or send an email to info@creativecommons.org for more information about the License.

Page Navigation

Date: 2014-11-10 09:55:43 +0000

The following are page variables available in Jekyll. I included only the variables used in the example. These descriptions are taken directly from the site.

Variable Description
page.title The title of the page.
page.url The URL of the post without the domain, but with a leading slash, e.g. /2008/12/14/my-post.html
page.date The Date assigned to the Post. This can be overridden in a Post’s front matter by specifying a new date/time in the format YYYY-MM-DD HH:MM:SS (assuming UTC), or YYYY-MM-DD HH:MM:SS +/-TTTT (to specify a time zone using an offset from UTC. e.g. 2008-12-14 10:30:00 +0900).
page.excerpt The un-rendered excerpt of the Page.
page.next The next post relative to the position of the current post in site.posts. Returns nil for the last entry.
page.previous The previous post relative to the position of the current post in site.posts. Returns nil for the first entry.

Here is an example of the next and previous page variables as initially implemented on this site.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<div id="page_previous">
    {% if page.previous != nil %} 
        <a href="{{ page.previous.url }}">Previous</a>
        <h1>{{ page.previous.title }}</h1>
        <p>
            {{ page.previous.excerpt }}<br/><br/>
            {{ page.previous.date | date_to_string}}
        </p>
    {% endif %}
</div>

<div id="page_next">
    {% if page.next != nil %}
        <a href="{{ page.next.url }}">Next</a>
        <h1>{{ page.next.title }}</h1>
        <p>
            {{ page.next.excerpt }}<br/><br/>
            {{ page.next.date | date_to_string}}
        </p>
    {% endif %}
</div>
  •  github pages