When connected to your Git repository, Pages allows you to control which environments and branches automatically deploy. By default, Pages triggers a deployment whenever you commit to either your production or preview environment. With branch deployment controls, you can configure automatic deployments on a per-project basis.
For branch build controls on Cloudflare Workers, refer to Workers Builds branch controls.
To configure deployment options:
-
In the Cloudflare dashboard, go to the Workers & Pages page.
Go to Workers & Pages ↗ -
Select your Pages project.
-
Go to Settings > Build > Branch control.
Pages defaults to setting your production environment to the branch you first push, but you can set your production branch to another branch.
You can also turn automatic deployment behavior on or off for the production branch using Enable automatic production branch deployments, then save your settings for the changes to take effect.
When configuring automatic preview deployments, there are three options to choose from.
- All non-Production branches: By default, Pages will automatically deploy any and every commit to a preview branch.
- None: Turns off automatic builds for all preview branches.
- Custom branches: Customize the automatic deployments of certain preview branches.
By selecting Custom branches, you can specify branches you wish to include and exclude from automatic deployments in the provided configuration fields. The configuration fields can be filled in two ways:
- Static branch names: Enter the precise name of the branch you are looking to include or exclude (for example, staging or dev).
- Wildcard syntax: Use wildcards to match multiple branches. You can specify wildcards at the start or end of your rule. The order of execution for the configuration is (1) Excludes, (2) Includes, (3) Skip. Pages will process the exclude configuration first, then go to the include configuration. If a branch does not match either then it will be skipped.
Example 1:
If you want to enforce branch prefixes such as fix/, feat/, or chore/ with wildcard syntax, you can include and exclude certain branches with the following rules:
- Include Preview branches:
fix/*,feat/*,chore/* - Exclude Preview branches: (leave empty)
Here Pages includes any branches with the indicated prefixes and skips everything else.
Example 2:
If you want to prevent Dependabot ↗︎ from creating a deployment for each PR it creates, you can exclude those branches with the following rules:
- Include Preview branches:
* - Exclude Preview branches:
dependabot/*
Here Pages includes all branches except any branch starting with dependabot/.
Example 3:
If you only want to deploy release-prefixed branches, leave Exclude Preview branches empty (excludes evaluate before includes, so setting * in excludes would skip every branch):
- Include Preview branches:
release/* - Exclude Preview branches: (leave empty)
This deploys only branches starting with release/ and skips all other branches.