Eleventy Static site generator
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
npx @11ty/eleventy
npx @11ty/eleventy --serve
npx @11ty/eleventy --input=<dir>
npx @11ty/eleventy --output=<dir>
npx @11ty/eleventy --watch
npx @11ty/eleventy --quiet
npx @11ty/eleventy --dryrun
layout: <file>
Concepts
- Data cascade
- Template md, njk, liquid, html
- Layout in _includes
- _site output folder
Running
npx @11ty/eleventy
npx @11ty/eleventy --serve
npx @11ty/eleventy --input=<dir>
npx @11ty/eleventy --output=<dir>
npx @11ty/eleventy --watch
npx @11ty/eleventy --quiet
npx @11ty/eleventy --dryrun
npx @11ty/eleventy --help
Front matter & layouts
layout: <file>
title: <text>
permalink: <path>
permalink: false
tags: <name>
date: <date>
{{ content | safe }}
{{ page.url }}Data cascade
| Source | Where |
|---|---|
Computed data |
eleventyComputed |
Template front matter |
the page itself |
Template data file |
<page>.11tydata.json |
Directory data file |
<dir>.11tydata.json |
Layout front matter |
layout file |
Config global data |
config API |
Global data file |
_data/*.json|js |
_data/<name>.json
_data/<dir>/<name>.json
<dir>/<dir>.11tydata.json
Collections & pagination
collections.<tag>
{% for post in collections.post %}
collections.post | reverse
pagination: data: <path>
size: <n>
pagination.items
pagination.pageNumber
pagination.href.next
Config file
eleventy.config.js
export default function (eleventyConfig) {}
export const config = { dir: { input, output } }
eleventyConfig.addPassthroughCopy("<path>")
eleventyConfig.addFilter("<name>", fn)
eleventyConfig.addCollection("<name>",
fn)
eleventyConfig.addPlugin(<plugin>)
Recipes
npm init -ynpm install --save-dev @11ty/eleventyecho '# Hello' > index.mdnpx @11ty/eleventy --serve
# posts/posts.11tydata.json{ "tags": "post", "layout": "post.njk" }# then, in a template{% for post in collections.post %} <a href="{{ post.url }}">{{ post.data.title }}</a>{% endfor %}
// eleventy.config.jsexport default function (eleventyConfig) { eleventyConfig.addPassthroughCopy("css");};export const config = { dir: { input: "src", output: "dist" } };
---pagination: data: collections.post size: 10permalink: "blog/{{ pagination.pageNumber }}/index.html"---



