Cloudflare Docs
Pages
Visit Pages on GitHub
Set theme to dark (⇧+D)

Build configuration

You may tell Cloudflare Pages how your site needs to be built as well as where its output files will be located.

Build commands and directories

You should provide a build command to tell Cloudflare Pages how to build your application. For projects not listed here, consider reading the tool’s documentation or framework, and submit a pull request to add it here.

Build directories indicates where your project’s build command outputs the built version of your Cloudflare Pages site. Often, this defaults to the industry-standard public, but you may find that you need to customize it.

Framework presets

Cloudflare maintains a list of build configurations for popular frameworks and tools. These are accessible during project creation. Below are some standard build commands and directories for popular frameworks and tools.

If you are not using a framework, leave the Build command field blank.

Framework/toolBuild commandBuild directory
Angular (Angular CLI)ng builddist
Brunchbrunch build --productionpublic
Docusaurusnpm run buildbuild
Eleventyeleventy_site
Ember.jsember builddist
Expoexpo build:webweb-build
Gatsbygatsby buildpublic
GitBookgitbook build_book
Gridsomegridsome builddist
Hugohugopublic
Jekylljekyll build_site
Jigsawvendor/bin/jigsaw build productionbuild_production
Mkdocsmkdocs buildsite
Next.js (Static HTML Export)next build && next exportout
Nuxt.jsnuxt generatedist
Pelicanpelican $content [-s settings.py]output
Quasarquasar builddist/spa
React (create-react-app)npm run buildbuild
React Staticreact-static builddist
Remixnpm run buildpublic
Slate./deploy.shbuild
Sveltenpm run buildpublic
Umiumi builddist
Vuenpm run buildpublic
VuePressvuepress build $directory$directory/.vuepress/dist

Environment variables

If your project makes use of environment variables to build your site, you can provide custom environment variables by going to Account Home > Pages > your Pages project > Settings > Environment variables.

The following system environment variables are injected by default (but can be overridden):

Environment VariableInjected valueExample use-case
CF_PAGES1Changing build behaviour when run on Pages versus locally
CF_PAGES_COMMIT_SHA<sha1-hash-of-current-commit>Passing current commit ID to error reporting, for example, Sentry
CF_PAGES_BRANCH<branch-name-of-current-deployment>Customizing build based on branch, for example, disabling debug logging on production

Language support and tools

Cloudflare Pages' build environment has broad support for a variety of languages, such as Ruby, Node.js, Python, PHP, and Go.

If you need to use a specific version of a language, (for example, Node.js or Ruby) you can specify it by providing an associated environment variable in your build configuration, or setting the relevant file in your source code.

Here are the pinned versions for tools included in the Cloudflare Workers build environment, and how to override them as relevant:

FrameworkDefault versionEnvironment variableFile
Elixir1.7
Erlang21
Go1.12GO_VERSION
Java8
Node.js12.18.0NODE_VERSION.nvmrc, .node-version
PHP5.6PHP_VERSION
Python2.7PYTHON_VERSIONruntime.txt, Pipfile
Ruby2.6.2RUBY_VERSION.ruby-version
.NET3.1.302

Many common tools have been pre-installed as well. The environment variable available for overriding the pinned version is specified, as available:

ToolsNotesEnvironment variable
Boot
Cask
Composer
DoxygenVersion 1.8.6
Emacs25
Gutenberg(requires environment variable)GUTENBERG_VERSION
HugoVersion 0.54HUGO_VERSION
GNU MakeVersion 3.8.1
ImageMagickVersion 6.7.7
jqVersion 1.5
Leiningen
OptiPNGVersion 0.6.4
NPMCorresponds with Node.js versionNPM_VERSION
pipCorresponds with Python version
PipenvLatest version
YarnVersion 1.13.0YARN_VERSION
Zola(requires environment variable)ZOLA_VERSION

If you want to set a specific version of a framework your Cloudflare Pages project is using, note that Pages will respect your package manager of choice during your build process. For example, if you use Gatsby.js, your package.json should indicate a version of the gatsby npm package, which will be installed using npm install as your project builds on Cloudflare Pages.