Eleventy is a static site generator that allows developers to build static websites using templates and data. It supports multiple templating languages and has flexible configuration options. Some key concepts of Eleventy include using front matter, templates, layouts, collections, and folders to organize content and data. Plugins and filters can be used to extend functionality and modify content. Data can come from local files or external APIs. Eleventy projects can be installed via npm and deployed to hosting platforms like Netlify which automate deployments from a Git repository.
9. Why are we interested in
static sites?
Eco-design
(consumes less server resources)
Security
(no server-side, no DB)
Cost reduction
(Hosting, maintenance)
Performance
(if well implemented!, CDN)
14. Front Matter quesako ?
- Instruction block composed of key/value and located in the header of
templates.
- Allows you to indicate instructions to Eleventy and to pass data to the
templates.
- Written in JSON, JavaScript or YAML. You can even add your own format!
18. Template quesako ?
- Templates are content files formatted via a tag system (HTML, Markdown)
or a more advanced templating language (Handlebars, Mustache, Liquid,
Nunjucks ...). Eleventy support 11 templating language !
- These templates indicate how the content and data should be used in the
pages that will be built by Eleventy.
26. Layout quesako ?
- Layouts are special templates for wrapping content in other content. It’s
quite similar to <slot> if you use a JS framework like React, Vue, Svelte ...
- Their use is optional, as templating languages like Nunjuncks have similar
functions.
31. Collection quesako ?
- A collection allows you to group content.
- Use the keyword “tags” in the frontmatter to attach a content in a collection.
- We can loop through a collection to display all their items.
- You can attach a content to several collection.
35. Folders & Files
By default all files in the root project folder will be compiled into the _site
directory.
root_project_folder
├── assets
├── file.md
├── file.njk
└── _site
Use an .eleventyignore file to let eleventy know which files you do not want to
compile.
36. Folders & Files
To copy your assets in the final static website, use addPassthroughCopy
root_project_folder / .eleventy.js
39. Data cascade quesako ?
- The data, depending on their origin, are read in a certain order and with a
certain priority.
We distinguish :
- Global data
- Data files that apply to a folder
- Data files that apply to a template
- The frontmatter data of a layout
- The frontmatter data of a template
- Computed data
https://benmyers.dev/blog/eleventy-data-cascade/
41. Plugins
- They allow to extend the functionalities of 11ty
- Step 1: install the plugin in your 11ty project via npm
- Step 2: call the plugin in your 11ty config file (.eleventy.js)
- Do something at the built step
- Examples:
> generate a RSS feed
> manage images optimization
> manage syntax highlighting ...
42. Plugins
- Step 1: in a terminal
- Step 2 : in your config file .eleventy.js
43. Filters
- They allow to modify a content
- Template language comes with built in filters
- Custom filter > definition of a "filterName" function in the .eleventy.js file
- Used in a template like this : {{ myContent | filterName }}
47. From files or an API
- Eleventy can work with data coming from different sources :
> Local files (md, html, templates …)
> Local data (frontmatter, global data …)
> External source (external API, Headless CMS API)
55. Deployment
- Version your project in a Git repository (Github, Gitlab, Bitbucket …).
- Choose a hosting company (Netlify, Vercel …).
- Link Netlify or whatever to your Git repository (dashboard).
- Allow Netlify or whatever and your Git platform to talk to each other (Git
platform SSH).
- Select your static site from your Git platform (dashboard).
- Configure your settings: branch, publish directory (dashboard).
- Use a build hook to watch your update on your Git repository and trigger an
automatic deployment.
56. Static sites ...
for which type of projects?
- Content Website (up to a certain size)
- Website with few daily update
Corporate website, documentation, blog, landing
page, portfolio, agency website ... and many more.
> 80% of Web ?
57. Eleventy
- Pretty fast build times.
- Zero-config by default but has flexible configuration
options.
- Works with your project’s existing directory structure.
- Node/javaScript ecosystem.
- Output pur HTML/CSS.
- Works with multiple template languages.
- Great use of data files/sources.
- OpenSource.
Con
Pro
- Sparse documentation.
- Limited tooling, community, tutorials.
- Not for very big website (build time, deployment)
- Do not manage dynamic part.
- You have to know how to write code to publish
content by default (Markdown).