Build with Astro
Create an Astro site from an Azion template, a GitHub repository, or the Azion CLI, and deploy it to an Azion domain.
You can deploy an Astro site on Azion from a template in Azion Console, from your GitHub repository, or with the Azion CLI. Every route ends with the site running on Azion and answering on an Azion domain.
Azion runs an Astro site as a static application. The build writes the site to ./dist, and the deploy uploads that folder to a storage bucket that an application serves. For the other frameworks Azion builds, refer to Frameworks compatibility.
Select the route you will use. The prerequisites and the deploy steps below follow that choice.
Prerequisites
- An Azion account. To create one, refer to Create an account.
- Access to Azion Console. To sign in, refer to How to access Azion Console.
- A GitHub account. A template deploy connects it when the form asks for it.
Astro templates
A template is a ready Astro project that Azion deploys for you. The Console route starts from one of these templates:
| Template | Use |
|---|---|
| Astro Audiophile | E-commerce |
| Astro Boilerplate | Starter project |
| Astro Blog Starter Kit | Blog creation |
| Astro Ecommerce | E-commerce platform |
| Astro with Multiple Frameworks | Starter project |
| Astro with Framework Preact | Starter project |
| Astro Minimal | Starter project |
| Astro with Non-HTML Pages | Non-HTML content |
| Astro Portfolio | Portfolio website |
| Astro Quickstore | E-commerce |
| Astro Starlog | Project release notes |
| Astro with Markdoc | Starter project |
| Astro Markdown with Plugins | Starter project |
| Astro Markdown with Shiki | Code demo |
| Astro with MDX | Starter project |
| Astro with Nano Stores | E-commerce |
| Astro with Tailwind CSS | Tailwind integration |
| Astro with Vitest | Starter project |
| Cosmic - Simple Astro Blog | Blog |
| Devscard | Developer portfolio |
| Clean Astro App with Sanity | CMS integration |
| Webpage to PDF Resume | Resume generator |
Two templates have a guide of their own, linked in the table. For more information on the others, refer to Azion Marketplace. In the CLI route, azion init lists the templates of the Astro preset in its own picker.
Deploy the site
Each route builds the Astro project and creates the resources that serve it on Azion. Follow the panel of the route you selected:
To create the project, run azion init with a name. In the two pickers, select Astro and then a template:
The -y option installs the dependencies, and --auto skips the questions about a local development server and a deploy. Without them, the command asks the questions that Azion CLI init lists. With the Astro Audiophile template, the command prints:
The command creates the project in a my-site folder. Its azion.config.mjs sets the astro preset and uploads ./dist to a storage bucket that workloads can only read. For every setting in that file, refer to azion.config.js.
To build the site, change to the project folder and run azion build:
The command runs the Astro build through Azion Bundler with the astro preset, and writes the site to dist:
To deploy the site, run azion deploy in the project folder:
The command uploads the project and opens the Console page that follows the deploy. It also prints that page’s URL in case the browser does not open. When the deploy ends, it prints the URL of the site’s domain. For the full output and every flag, refer to Azion CLI deploy.
To run the site on your machine before you deploy it, refer to Azion CLI dev. To deploy an Astro project that already exists, run azion link in its folder and select the Astro preset, as Azion CLI link describes.
Check the site
The deploy returns the URL of the site’s Azion domain, in the form https://xxxxxxxxxx.map.azionedge.net. Azion Console shows it on the deploy page, and azion deploy prints it when it ends. Open the URL in a browser to see the Astro site.
The first deploy can take several minutes to answer from every location; later deploys take about two minutes. Until a location receives the site, the domain answers with a 404 page that reads There's nothing here yet. On that response, wait and request the URL again.