Public
Like
dprn-remix
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
| title: | Building Static Sites with Eleventy | |||
|---|---|---|---|---|
| description: | A guide to getting started with Eleventy static site generator | |||
| date: | 2024-01-20T00:00:00.000Z | |||
| tags: |
|
Eleventy (11ty) is a simpler static site generator that's gained popularity for its flexibility and ease of use. In this post, I'll share some tips for building great static sites with Eleventy.
Eleventy supports many template languages out of the box:
- Markdown
- Nunjucks
- Liquid
- Handlebars
- Mustache
- EJS
- Haml
- Pug
Collections are a powerful way to group related content:
// In .eleventy.js
eleventyConfig.addCollection("posts", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/posts/*.md");
});
Custom filters help transform data:
eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
});
- Organize your content - Use clear folder structures
- Use data files - Store site-wide data in
_data/ - Create reusable includes - Build modular templates
- Optimize images - Use appropriate formats and sizes
- Test locally - Always test before deploying
- Minimize CSS and JavaScript
- Optimize images
- Use semantic HTML
- Implement proper caching headers
- Consider a CDN for static assets
Eleventy makes it easy to build fast, maintainable static sites. Give it a try for your next project!