Cloudflare is a cloud solutions provider with a huge proprietary content delivery network (CDN). Like Netlify or Vercel, Cloudflare Pages makes the deployment process flexible and easy. You can add a GitHub repo to the service and build & host Zola-based websites after each PR automatically.
ZOLA_VERSION
as a variable name. Use 0.17.2
or a different Zola version as the value.Your website is now built and deployed to Cloudflare's network! You can add a custom domain or modify settings in the Pages dashboard.
You may find documentation and guides like Getting started with Cloudflare Pages and Deploying Zola with Cloudflare Pages in the Developers portal.
When working with Cloudflare Pages, you'll often use preview deployments for testing changes before merging to your main branch. By default, these preview deployments use different URLs (like https://your-branch-name.your-project.pages.dev
), which can cause issues with asset loading if your base_url
is hardcoded in your config.toml
.
To fix this, modify your build command in the Cloudflare Pages configuration to dynamically set the base URL depending on the environment:
if [ "$CF_PAGES_BRANCH" = "main" ]; then zola build; else zola build --base-url $CF_PAGES_URL; fi
This command:
config.toml
base_url
when building from the main branch$CF_PAGES_URL
) for all other branchesSome tips to help troubleshoot issues getting started with Cloudflare Pages.
zola: not found
If you see build output that resembles something like this:
23:03:54.609 > build
23:03:54.609 > zola build $BUILD_OPTS && npx tailwindcss -i ./public/input.css -o ./public/style.css -m
23:03:54.609
23:03:54.621 sh: 1: zola: not found
23:03:54.635 Failed: Error while executing user command. Exited with error code: 127
23:03:54.644 Failed: build command exited with code: 1
23:03:55.699 Failed: error occurred while running build command
Then it might be due to an outstanding issue. There are currently two recommended workarounds:
v1
From within the workers & pages dash, go to the following:
Then select v1
and save.
UNSTABLE_PRE_BUILD
environment variable + asdf
From within the workers & pages dash, do the following:
And add an environment variable UNSTABLE_PRE_BUILD
, with the following value and save.
asdf plugin add zola https://github.com/salasrod/asdf-zola && asdf install zola 0.18.0 && asdf global zola 0.18.0