Page/Post properties
These properties are automatically set for pages and other content that have been processed, e.g {{ post.autogen }}
Field | Description |
---|---|
permalink |
Relative path of the current page |
hidden |
true for all pages (including the single-page view) except the first page |
tag , tags |
nil for all except the first page |
category , categories |
nil for all except the first page |
autogen |
“jekyll-paginate-content” for all pages |
pagination_info |
.curr_page = current page number.total_pages = total number of pages.type = “first”, “part”, “last”, or “single”.id = a string which is the same for all related pages |
The tags, categories, and hidden
are set up this way to avoid duplicate counts and having the parts show up in e.g. your tag index listings. You may override this behavior as discussed below.
Setting custom properties
paginate_content
has a properties
option:
paginate_content:
properties:
all:
field1: value1
# ...etc...
first:
field2: value2
# ...etc...
part:
field3: value3
# ...etc...
last:
field4: value4
# ...etc...
single:
field5: value5
# ...etc...
where the properties/fields listed under all
will be set for all pages, first
properties for the first page (possibly overriding values in all
), etc.
Example: To help with your layouts, you may want to set a property for the single-page view, say, activating comments:
paginate_content:
properties:
single:
comments: true
In your layout, you’d use something like
{% if post.comments %}
<!-- Disqus section -->
{% endif %}
The single-page view would then show the Disqus comments section.
Overriding and restoring properties
You can set almost any front-matter property via the properties
section, except for title
, date
, permalink
, and pagination_info
. Use with caution.
Special values
You may use the following values for properties:
Value | Meaning |
---|---|
~ |
nil (essentially disabling the property) |
$ |
The original value of the property |
$.property |
The original value of the specified property |
/ |
Totally remove this property |
Default properties
For reference, the default properties effectively map out to:
properties:
all:
autogen: 'jekyll-paginate-content'
hidden: true
tag: ~
tags: ~
category: ~
categories: ~
pagination_info:
curr_page: (a number)
total_pages: (a number)
id: '(a string)'
first:
hidden: false
tag: $
tags: $
category: $
categories: $
pagination_info:
type: 'first'
part:
pagination_info:
type: 'part'
last:
pagination_info:
type: 'last'
single:
pagination_info:
curr_page: /
total_pages: /
type: 'single'
Example: blog
The author’s _config.yml
has the following:
properties:
all:
comments: false
share: false
x_title: $.title
#first:
# keeps original tags and categories
part:
x_tags: []
x_cats: []
last:
comments: true
share: true
x_tags: $.tags
x_cats: $.categories
single:
comments: true
share: true
x_tags: $.tags
x_cats: $.categories
x_tags
and x_cats
are used in this case to store the original tags and categories for generating a list of related posts only for last pages or single-page views. comments
and share
are likewise used to turn on the sections for comments and social media sharing for these pages.
x_title
saves the original title for use in social media sharing. The example below also does something similar for the URL to be shared:
{% if page.x_title %}
{% assign share_title = page.x_title %}
{% else %}
{% assign share_title = page.title %}
{% endif %}
{% if paginator.first_path %}
{% assign share_url = paginator.first_path %}
{% else %}
{% assign share_url = page.url %}
{% endif %}
Example: slides/presentation
JPC can be used to generate slides as well as a detailed document from the same source Markdown, i.e.
{% if paginator.paginated %}
// Content that only shows up in the slides
{% else %}
// Content that only shows up in the single/details page.
{% endif %}
Or alternatively,
{% if paginator.paginated %}
// Content that only shows up in the slides
{% endif %}
and
{% unless paginator.paginated %}
// Content that only shows up in the single/details page.
{% endif %}
Here’s an example configuration:
properties:
all:
layout: slides
single:
layout: $
This makes all pages except the single-page view use the slides
layout. The latter will use the original layout.
Last slide
When using JPC to generate slides, you may use _last_
as the title for the last slide (usually a “thank you” or contact info slide). It will be removed and hidden from the TOC.
The demos include a sample presentation.