eleventy
A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
Top Related Projects
Quick Overview
Eleventy (11ty) is a simple static site generator written in JavaScript. It transforms a directory of templates into HTML, using various templating languages and data sources. Eleventy is designed to be flexible, fast, and easy to use for developers of all skill levels.
Pros
- Flexible and unopinionated, allowing developers to use their preferred templating languages and folder structures
- Fast build times, especially for larger sites
- Zero-config by default, but highly customizable
- Excellent documentation and active community support
Cons
- Steeper learning curve compared to some other static site generators
- Lack of built-in asset pipeline (requires additional plugins or tools)
- Limited built-in themes or starter templates
- May require more setup for complex projects compared to full-featured frameworks
Code Examples
- Basic configuration (
.eleventy.js
):
module.exports = function(eleventyConfig) {
// Copy the `img` and `css` folders to the output
eleventyConfig.addPassthroughCopy("img");
eleventyConfig.addPassthroughCopy("css");
return {
passthroughFileCopy: true,
dir: {
input: "src",
output: "dist"
}
};
};
- Creating a custom filter:
eleventyConfig.addFilter("myCustomFilter", function(value) {
return value.toUpperCase();
});
- Using front matter in a Markdown file:
---
layout: post
title: My First Blog Post
date: 2023-04-15
---
# Welcome to my blog
This is the content of my first blog post.
Getting Started
-
Install Eleventy:
npm install -g @11ty/eleventy
-
Create a new project directory and navigate to it:
mkdir my-eleventy-project cd my-eleventy-project
-
Create an
index.md
file with some content:# Hello, Eleventy! This is my first Eleventy page.
-
Run Eleventy:
eleventy
-
Your generated site will be in the
_site
directory. To serve it locally:eleventy --serve
Competitor Comparisons
The world’s fastest framework for building websites.
Pros of Hugo
- Faster build times, especially for large sites
- Built-in asset pipeline for processing CSS, JS, and images
- More extensive theming system with easier customization
Cons of Hugo
- Steeper learning curve due to Go templating language
- Less flexibility in terms of data sources and processing
- More complex configuration for advanced features
Code Comparison
Hugo (Go templates):
{{ range .Pages }}
<h2>{{ .Title }}</h2>
{{ .Content }}
{{ end }}
Eleventy (Nunjucks):
{% for post in collections.posts %}
<h2>{{ post.data.title }}</h2>
{{ post.templateContent | safe }}
{% endfor %}
Both Hugo and Eleventy are popular static site generators, but they have different approaches. Hugo is known for its speed and built-in features, making it suitable for larger projects. Eleventy, on the other hand, offers more flexibility and a gentler learning curve, especially for developers familiar with JavaScript.
Hugo's Go-based templating can be challenging for newcomers, while Eleventy's use of various templating languages (like Nunjucks, Liquid, or even plain JavaScript) provides more options. However, Hugo's performance edge and comprehensive asset handling make it a strong choice for complex sites.
Ultimately, the choice between Hugo and Eleventy depends on project requirements, team expertise, and personal preferences.
The best React-based framework with performance, scalability and security built in.
Pros of Gatsby
- Rich ecosystem with a vast plugin library and themes
- Built-in GraphQL for efficient data querying and management
- Advanced performance optimizations like image processing and code splitting
Cons of Gatsby
- Steeper learning curve, especially for developers new to React or GraphQL
- Longer build times for large sites due to complex data processing
- Higher resource consumption and potential overhead for simpler projects
Code Comparison
Eleventy (Basic configuration):
module.exports = function(eleventyConfig) {
return {
dir: {
input: "src",
output: "dist"
}
};
};
Gatsby (Basic configuration):
module.exports = {
siteMetadata: {
title: `My Gatsby Site`,
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-image`,
],
};
Eleventy focuses on simplicity and flexibility, allowing developers to use various templating languages and have more control over the build process. Gatsby, on the other hand, provides a more opinionated structure with React and GraphQL at its core, offering powerful features out of the box but with added complexity.
The React Framework
Pros of Next.js
- Built-in server-side rendering and static site generation
- Seamless integration with React and its ecosystem
- Automatic code splitting for optimized performance
Cons of Next.js
- Steeper learning curve for developers new to React
- More complex setup and configuration compared to simpler static site generators
- Potentially higher resource usage for server-side rendering
Code Comparison
Next.js:
import { useEffect, useState } from 'react'
function HomePage() {
const [data, setData] = useState(null)
useEffect(() => {
fetch('/api/data').then(res => res.json()).then(setData)
}, [])
return <div>{data ? data.message : 'Loading...'}</div>
}
Eleventy:
---
layout: layout.njk
---
<div>{{ data.message }}</div>
Next.js offers a more dynamic approach with React components and client-side data fetching, while Eleventy focuses on simplicity and static content generation. Next.js is better suited for complex, interactive applications, whereas Eleventy excels in creating lightweight, static websites with minimal JavaScript.
The Intuitive Vue Framework.
Pros of Nuxt
- Built-in Vue.js integration for dynamic, reactive web applications
- Server-side rendering capabilities for improved SEO and performance
- Extensive ecosystem with plugins and modules for added functionality
Cons of Nuxt
- Steeper learning curve, especially for developers new to Vue.js
- Potentially larger bundle size due to included features and dependencies
- More complex setup and configuration compared to simpler static site generators
Code Comparison
Eleventy (Basic configuration):
module.exports = function(eleventyConfig) {
// Add configuration here
return {
dir: {
input: "src",
output: "dist"
}
};
};
Nuxt (Basic configuration):
export default {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'My Nuxt App'
}
}
Both Eleventy and Nuxt are popular static site generators, but they cater to different needs. Eleventy focuses on simplicity and flexibility, supporting multiple template languages and allowing developers to bring their own frontend tools. Nuxt, on the other hand, is tightly integrated with Vue.js and provides a more opinionated structure for building full-featured web applications with server-side rendering capabilities.
A fast, simple & powerful blog framework, powered by Node.js.
Pros of Hexo
- Built-in asset pipeline for handling CSS, JavaScript, and images
- Extensive plugin ecosystem with over 280 official plugins
- Supports multiple languages and internationalization out of the box
Cons of Hexo
- Steeper learning curve due to its more complex configuration
- Slower build times for large sites compared to Eleventy
- Less flexibility in templating languages, primarily focused on EJS and Swig
Code Comparison
Hexo configuration (hexo.config.js):
module.exports = {
title: 'My Site',
theme: 'landscape',
deploy: {
type: 'git',
repo: 'https://github.com/user/repo.git'
}
};
Eleventy configuration (.eleventy.js):
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("img");
return {
dir: { input: "src", output: "dist" }
};
};
Both Hexo and Eleventy are popular static site generators, but they differ in their approach and features. Hexo offers a more opinionated structure with built-in asset handling and a rich plugin ecosystem, making it suitable for bloggers who want a quick start. Eleventy, on the other hand, provides more flexibility in templating and configuration, allowing developers to have fine-grained control over their build process. The choice between the two depends on the specific needs of the project and the developer's preferences.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
eleventy ðâ¡ï¸ðð
A simpler static site generator. An alternative to Jekyll. Written in JavaScript. Transforms a directory of templates (of varying types) into HTML.
Works with HTML, Markdown, JavaScript, Liquid, Nunjucks, with addons for WebC, Sass, Vue, Svelte, TypeScript, JSX, and many others!
â¡ Documentation
- Please star this repo on GitHub!
- Follow us on Mastodon @eleventy@fosstodon.org or Twitter @eleven_ty
- Join us on Discord
- Support 11ty on Open Collective
- 11ty on npm
- 11ty on GitHub
Installation
npm install @11ty/eleventy --save-dev
Read our Getting Started guide.
Tests
npm run test
- We use the ava JavaScript test runner (Assertions documentation)
- â¹ï¸ To keep tests fast, thou shalt try to avoid writing files in tests.
- Continuous Integration on GitHub Actions
- Code Coverage Statistics
- Benchmark for Performance Regressions
Community Roadmap
- Top Feature Requests (Add your own votes using the ð reaction)
- Top Bugs ð± (Add your own votes using the ð reaction)
Plugins
See the official docs on plugins.
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot