Zero config blog features for 11ty
This plugin still requires a bit of love in terms of documentation. See my personal blog code to see all examples of use.
- Tags, Categories and API to create new taxonomies (paginated)
- Calendar (paginated)
npm install --save eleventy-plugin-blog
# OR
yarn add eleventy-plugin-blog
Go to the folder with given example and run:
../../generate-examples.js -o . -n 500
npx @11ty/eleventy
All massive output will be created balazzingly fast to show you how it works.
To start using you just need to add the plugin into your .eleventy.js
file.
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(require("eleventy-plugin-blog"));
};
This will produce following collections:
blog
all posts, paginatedblog_flat
all posts, flatall
all pages (using native 11ty)pages
all pages with frontmatterpage: true
tag
posts grouped by tags, paginatedcategory
posts grouped by categories, paginatedcategory_list
list of all categoriestag_list
list of all tagscalendar
posts grouped by year or year and month, paginated
See example zero config for all templates.
- See my blog repository: https://github.com/sielay/sielay.com
See life example
<ul>
{%- for post in postslist.items -%}
<li>
{%- include 'tile.njk' -%}
</li>
{%- endfor -%}
</ul>
Create paginated index of pages
Field | Type | Description |
---|---|---|
pages | Iterable | Collection of 11ty pages |
slug | String | Slug to be applied (see notes below) |
prefix | String | Slug prefix |
title | String | Given title |
meta | Object | Undefiend | Additional data to bound to each index page (see generateCalendar |
itemsPerPage | Number | Number of 11ty pages on each index page |
sortBlog | Function | Undefined |
Slugs will be generated as follows:
- First page
${slug}
- Every next page
${slug}/page-${pageNumber}
Field | Type | Description |
---|---|---|
title | String | Given title |
slug | String | Generated slug (as described above) |
pagenumber | Number | Number of given page (starting from 0) |
url | String | Concatenated value from prefix and slug |
total | Number | Number of pages |
slugs | Slugs | |
items | Page[] | 11typ pages on given page |
...meta | Anything that came from meta input |
Field | Type | Description |
---|---|---|
all | String[] | List of all pages slugs |
next | String | Null | Slug of the next page |
previous | String | Null | Slug of the previous page |
first | String | Null | Slug of the first page |
last | String | Null | Slug of the last page |
See live example
---
title: Blog
pagination:
data: collections.blog
size: 1
alias: postslist
permalink: /blog/{%- if postslist.pagenumber > 0 -%}{{ postslist.pagenumber }}{%- endif -%}/index.html
topNav: postslist.pagenumber == 0
---
{%- include 'postslist.njk' -%}
Generates simple paginated blog. Uses paginage
over given blog globs and can apply template
Field | Type | Description |
---|---|---|
blogPostTemplate | String | Undefined | Path to blog post template |
blog | String[] | Globs for blog posts |
itemsPerPage | Number | Custom number of items per page |
See live example - indirect use
For a template example see paginate.
Generates calendar grouping by years and months.
Field | Type | Description |
---|---|---|
blog | String[] | Globs for blog posts |
itemsPerPage | Number | Custom number of items per page |
IndexPage objects generated here will be extended using meta
field with
Field | Type | Description |
---|---|---|
year | String | Year for annual group |
month | String | Undefined | Month for monthly group |
type | 'year' | 'month' | Type of group |
shortTitle | String | Undefined | Formatted title for month groups |
TBD
TBD
TBD
TBD
TBD
TBD
Inspired by Jérôme Coupé