Cloudflare Docs
View GitHub RSS feed
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.

Understanding your build configuration

The build command is provided by your framework. For example, the Gatsby framework uses gatsby build as its build command. When you are working without a framework, leave the Build command field blank.

The build directory is generated from the build command. Each framework has its own naming convention, for example, the build output directory is named /public for many frameworks.

The root directory is where your site’s content lives. If not specified, Cloudflare assumes that your linked git repository is the root directory. The root directory needs to be specified in cases like monorepos, where there may be multiple projects in one repository.

​​ 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)npx ng build --proddist
Astronpm run builddist
Brunchnpx brunch build --productionpublic
Create React Appnpm run buildbuild
Docusaurusnpm run buildbuild
Elder.jsnpm run buildpublic
Eleventynpx @11ty/eleventy_site
Ember.jsnpx ember-cli builddist
Gatsbynpx gatsby buildpublic
GitBooknpx gitbook-cli build_book
Gridsomenpx gridsome builddist
Jekylljekyll build_site
MkDocsmkdocs buildsite
Next.jsnpx @cloudflare/next-on-pages@1.vercel/output/static
Next.js (Static HTML Export)npx next buildout
Nuxt.jsnpm run builddist
Pelicanpelican contentoutput
Qwiknpm run builddist
React Staticreact-static builddist
Remixnpm run buildpublic
Sveltenpm run buildpublic
SvelteKitnpm run build.svelte-kit/cloudflare
Uminpx umi builddist
Vuenpm run builddist
VuePressnpx vuepress build.vuepress/dist
Zolazola buildpublic

​​ Environment variables

If your project makes use of environment variables to build your site, provide custom environment variables:

  1. Log in to the Cloudflare dashboard and select your account.
  2. In Account Home, select Workers & Pages > in Overview,select your Pages project.
  3. Select 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
CF_PAGES_URL<url-of-current-deployment>Allowing build tools to know the URL the page will be deployed at

​​ Language support and tools

Moved to Language support and tools.