Deprecation notice: There is now an official archive plugin, Jekyll Archives. To avoid confusion and duplication of effort, 0.4.0 is planned to be the final release of Jekyll Archive Generator and you should probably use Jekyll Archives instead.
This plugin creates a set of archive pages for a Jekyll website.
Oddly, Jekyll doesn't include a date-based archive for posts out of the box. For example, if you have a permalink structure like blog/2014/01/01/title
, URL hacking won't work because going to blog/2014
will return 404 Page Not Found.
Jekyll Archive Generator fixes that by generating all the necessary archive pages for each part of your blog URL structure.
This plugin is provided as a gem:
gem install jekyll-itafroma-archive
Once the gem is installed, include it in your Jekyll site's configuration:
gems: ['jekyll/itafroma/archive']
This plugin's configuration is contained within the archive
key and supports multiple archives:
archive:
- path: /blog/:year
layout: archive_blog
title: Blog archive — :year
include:
tags: ['PHP']
exclude:
categories: ['news']
tags: ['drafts']
- path: /blog/:year/:month
layout: archive_blog
title: Blog archive — :month :year
include:
tags: ['PHP']
exclude:
categories: ['news']
tags: ['drafts']
- path: /blog/:year/:month/:day
layout: archive_blog
title: Blog archive — :month :day, :year
include:
tags: ['PHP']
exclude:
categories: ['news']
tags: ['drafts']
All directives are optional.
The tokenized path where the archive should be generated. For example, /blog/:year
will generate a set of archive pages corresponding to post years: /blog/2010
, /blog/2011
, and so on. The following tokens are available:
year
: four-digit yearshort_year
: two-digit yearmonth
: month with leading zerosi_month
: month without leading zerosshort_month
: three-letter, capitalized month name (e.g. "Jan")long_month
: full, capitalized month name (e.g. "January")day
: day with leading zerosi_day
: day without leading zerosy_day
: day of the year (e.g. 252)Default value: /
The name of the layout to use for the archive pages. An example layout named archive.html
is included in this repository. See Usage below for more information.
Default value: archive
The tokenized title of the archive pages. This uses the same tokens available for the path
directive above. For example, Blog archive — :year
will generate archive page titles like Blog Archive — 2010, Blog Archive — 2011, and so on.
Default value: Blog archive
A mapping of front matter keys used to "whitelist" posts for the archive. Each key in the mapping is an array of strings for that specific key to include. This is conjunctive: if a post matches at least one condition, it will be included in the archive.
For example, categories: ['foo', 'bar']
will ensure that only posts in the foo
or bar
categories will be included in the archive.
If include
is not present, all posts will be included in the archive.
Default value: empty (all posts will be included)
A mapping of front matter keys used to exclude posts from the archive. Each key in the sequence is an array of strings for that specific key to exclude.
For example, categories: ['foo', 'bar']
will exclude any post that has the foo
or bar
category.
Exclusion filters are run after inclusion criteria specified by the include
directive.
Default value: empty (no posts will be excluded)
An example layout named archive.html
is included in this repository. Two variables are exposed to the archive layout:
The collection of posts for the specific time period in the archive. For example, page.archive.posts
will only contain posts from May 2014 in the May 2014 archive page.
A paginator to navigate between archive pages at a specific date "resolution". For example, on the archive page for May 2014, the paginator will let you navigate between months. On the archive page for May 26, 2014, the paginator will let you navigate between days.
This paginator contains many of the same values found in Jekyll's native paginator (description of variables copied from that page):
page.archive.paginator.page
: the current page numberpage.archive.paginator.total_pages
: the number of pagination pagespage.archive.paginator.previous_page
: the page number of the previous pagination page, or nil
if no previous page existspage.archive.paginator.previous_page_path
: the path of previous pagination page, or nil
if no previous page existspage.archive.paginator.next_page
: the page number of the next pagination page, or nil
if no subsequent page existspage.archive.paginator.next_page_path
: the path of next pagination page, or nil
if no subsequent page existsThis plug is inspired by the work done by Nicholas Lindley:
And by Ilkka Laukkanen:
This plugin is copyright © 2013–2015 Mark Trapp. All rights reserved. It is made available via the MIT license. A copy of the license can be found in the LICENSE
file.