Simple 11ty static website generator with minimum config required.
It's based on the amazing 11ty static site generator! You can find an overview 2 min video about Eleventy here: https://www.youtube.com/watch?v=EZfNr-YblBE
⭐️ See this project live: https://static-11ty.netlify.app
- Generate a repo from this template which will copy this project into your own new repo.
- Clone your repo.
$ npm install$ npm start- 🤩 Enjoy.
This is a super simple static website setup built on top of 11ty. It has only one package dependency, 11ty itself!
1. ⚙️ Nunjucks template system
It has a base.njk with your main HTML template.
If you don't want to use njk, you can "compile" simple HTML files, such as no-template-sample-page.html
During the build, 11ty will generate an uuid of 8 characters to be used as unique value to be apended at the end of static files to avoid CDN cache issues. E.g.:
<script src="/assets/js/script.js?v={%VERSION%}"></script>
will be replaced to:
<script src="/assets/js/script.js?v=zpuf45ww"></script>During the build, 11ty will replace the {%BASE_URL%} inside njk, html, css and js files by a BASE_URL defined env variable. The default value is: http://localhost:8080. E.g:
<script src="{%BASE_URL%}/assets/js/script.js"></script>
will be replaced to:
<script src="http://localhost:8080/assets/js/script.js"></script>During the website deploy, set the BASE_URL env variable to the desired value. E.g.:
BASE_URL=https://myawesomewebsite.comTo force the BASE_URL website generation locally, you can run:
$ BASE_URL=https://myawesomewebsite.com npm run buildThe project itself is a sample project, using all the features. Checkout the src folder!
You can find a simple "set current page active" on the src/_includes/base.njk using Nunjucks template.
You can have some sort of analytics tracker and one specific tracking per page. You can find the usage example at the bottom of the index.njk file.
Automatic sitemap generator using the sitemap.njk!
11ty only requires Node.js and supports most operating systems.
- Node.js 12+
- npm 6.14+
-
Generate a repo from this template which will copy this project into your own new repo. Note: You must be signed in to GitHub for this link to work, else visit the repo directly.
-
Once cloned,
run npm installto install 11ty. Thenrun npm startto run 11ty inservemode which will create a local server including hot-reload via BrowserSync.Use
npm run buildto run a production version. -
Open
src/_data/site.jsand adjust the values to your details (specially the website name). -
Edit
index.njkto change the home page, and then create content withinsrcfolder to add content.
$ npm startOr the very popular alias dev
$ npm run devIt will launch a local server at http://localhost:8080 with live reload enabled.
By default, 11ty generates a _site folder with the transformed files inside.
It is required to set the set the env variable BASE_URL with the full path URL:
BASE_URL=https://static-11ty.netlify.app
Default value of BASE_URL http://localhost:8080 from the .eleventy.js file.
$ npm run buildTo force the BASE_URL website generation locally, you can run:
$ BASE_URL=https://myawesomewebsite.com npm run build11ty will output the website at _site folder.