This guide shows you how to deploy a Zola application to Edgio.
Example
Prerequisites
Setup requires:
- An Edgio account. Sign up for free.
- An Edgio property. Learn how to create a property.
- Node.js. View supported versions and installation steps.
- Edgio CLI.
Install the Edgio CLI
If you have not already done so, install the Edgio CLI.
Bash
1npm i -g @layer0/cli@latest
Create a new Zola app
Step 1: Install Zola
Bash
1brew install zola2# or3sudo port install zola
To verify your new install:
Bash
1zola --version
Step 2: Create a New Site
Bash
1zola init myblog
You will be asked a few questions.
Bash
1> What is the URL of your site? (https://example.com):2> Do you want to enable Sass compilation? [Y/n]:3> Do you want to enable syntax highlighting? [y/N]:4> Do you want to build a search index of the content? [y/N]:
For our blog, let’s accept the default values (i.e., press Enter for each question). We now have a
myblog
directory with the following structure:Directory
1├── config.toml2├── content3├── sass4├── static5├── templates6└── themes
For reference, by the end of this overview, our
myblog
directory will have the following structure:Directory
1├── config.toml2├── content/3│ └── blog/4│ ├── _index.md5│ ├── first.md6│ └── second.md7├── sass/8├── static/9├── templates/10│ ├── base.html11│ ├── blog-page.html12│ ├── blog.html13│ └── index.html14└── themes/
Step 3: Start the Zola server
Let’s start the Zola development server with:
Bash
1zola serve2Building site...3-> Creating 0 pages (0 orphan), 0 sections, and processing 0 images
Configuring your Zola app for Edgio
Create a
package.json
at the root of your project with the following:Bash
1npm init
Initialize your project
In the root directory of your project run
0 init
:Bash
10 init
This will automatically update your
package.json
and add all of the required Edgio dependencies and files to your project. These include:- The
@layer0/core
package - Allows you to declare routes and deploy your application on Edgio - The
@layer0/prefetch
package - Allows you to configure a service worker to prefetch and cache pages to improve browsing speed layer0.config.js
- A configuration file for Edgioroutes.js
- A default routes file that sends all requests to Zola.
Configure the routes
Update
routes.js
at the root of your project to the following:JavaScript
1// This file was added by layer0 init.2// You should commit this file to source control.34import { Router } from '@layer0/core/router'56export default new Router()7 // Prevent search engine bot(s) from indexing8 // Read more on: https://docs.layer0.co/applications/cookbook#blocking-search-engine-crawlers9 .noIndexPermalink()10 .static('public', ({ cache }) => {11 cache({12 edge: {13 maxAgeSeconds: 60 * 60 * 60 * 365,14 forcePrivateCaching: true,15 },16 browser: {17 maxAgeSeconds: 0,18 serviceWorkerSeconds: 60 * 60 * 24,19 },20 })21 })
Refer to the Routing guide for the full syntax of the
routes.js
file and how to configure it for your use case.Run the Zola app locally on Edgio
Create a production build of your app by running the following in your project’s root directory:
Bash
1npm run build
Test your app with the Sites on your local machine by running the following command in your project’s root directory:
Bash
10 dev
Load the site http://127.0.0.1:3000
Deploying
Create a production build of your app by running the following in your project’s root directory:
Bash
1npm run build
Deploy your app to the Sites by running the following command in your project’s root directory:
Bash
10 deploy
Refer to the Deploying guide for more information on the
deploy
command and its options.