Build with Docusaurus
Create a Docusaurus site from an Azion template or the Azion CLI, and deploy it to an Azion domain.
You can deploy a Docusaurus site on Azion from a template in Azion Console or with the Azion CLI. Both routes end with the site running on Azion and answering on an Azion domain.
Azion runs a Docusaurus site as a static application. The build writes the site to ./build, 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.
Docusaurus templates
A template is a ready Docusaurus project that Azion deploys for you. The Console route starts from one of these templates:
| Template | Use |
|---|---|
| Docusaurus JavaScript Boilerplate | Starter project in JavaScript |
| Docusaurus TypeScript Boilerplate | Starter project in TypeScript |
Each template has a guide of its own, linked in the table. For more information on templates, refer to Azion Marketplace. In the CLI route, azion init lists the same two starters as Docusaurus Boilerplate (JS) and Docusaurus Boilerplate (TS).
Deploy the site
Each route builds the Docusaurus 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 Docusaurus 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 Docusaurus Boilerplate (JS) template, the command prints:
The command creates the project in a my-site folder. Its azion.config.cjs sets the docusaurus preset and uploads ./build 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 Docusaurus build through Azion Bundler with the docusaurus preset, and writes the site to build. The Docusaurus build prints warnings about the template’s configuration and blog posts, and still succeeds:
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 a Docusaurus project that already exists, run azion link in its folder and select the Docusaurus 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 Docusaurus 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.