Build with Eleventy
Create an Eleventy site with the Azion CLI, build it, and deploy it to an Azion domain.
Use the Azion CLI to create an Eleventy site from a template, build it, and deploy it. When the deploy ends, the site runs on Azion and answers on an Azion domain.
Azion runs an Eleventy site as a static application. The build writes the pages to ./_site. The deploy then uploads that folder to a storage bucket, and an application serves the files from it. For the other frameworks that Azion builds, refer to Frameworks compatibility.
Prerequisites
- An Azion account. To create one, refer to Create an account.
- The Azion CLI, installed and logged in. For the setup, refer to Azion CLI quickstart.
- Node.js 18 or later, with npm.
- A terminal and a code editor.
Deploy the site
The CLI creates the project, builds it, and creates the resources that serve it on Azion.
To create the project, run azion init and give it a name. In the first picker, select Eleventy. In the second picker, select a template:
With -y, the command installs the dependencies. With --auto, it does not ask whether to start a local development server or to deploy. Without these options, the command asks the questions listed in Azion CLI init. This is the output for the 11ty Base Blog template:
The project is in the my-site folder. Its azion.config.cjs file sets the eleventy preset and uploads ./_site to a storage bucket that workloads have read-only access to. For every setting in that file, refer to azion.config.js.
To build the site, go to the project folder and run azion build:
Azion Bundler runs the Eleventy build with the eleventy preset, and the pages go to _site:
To deploy the site, run azion deploy from the project folder:
The CLI uploads the project and opens a Console page where you can follow the deploy. If the browser does not open, use the URL of that page, which the CLI also prints. At the end of the deploy, the CLI prints the URL of the site’s domain. For the full output and the flags of the command, refer to Azion CLI deploy.
To run the site on your computer before the deploy, refer to Azion CLI dev. To deploy an Eleventy project that you already have, run azion link in its folder and select eleventy in the preset list. For more information, refer to Azion CLI link.
Check the site
At the end of the deploy, azion deploy prints the URL of the site’s Azion domain, in the form https://xxxxxxxxxx.map.azionedge.net. Open that URL in a browser to see the Eleventy site.
The first deploy can take several minutes to answer from every location; later deploys take about two minutes. A location that has not received the site yet answers with a 404 page that reads There's nothing here yet. If you get that page, wait and open the URL again.