When you connect a Git repository to Pages, by default a change to any file in the repository triggers a Pages build. You can configure Pages to include or exclude specific paths to skip builds for unrelated changes. This is useful in a monorepo project structure to limit unnecessary builds. For build watch paths on Cloudflare Workers, refer to Workers Builds build watch paths.
To configure which paths are included and excluded:
-
In the Cloudflare dashboard, go to the Workers & Pages page.
Go to Workers & Pages ↗ -
Select your Pages project.
-
Go to Settings > Build > Build watch paths. Pages defaults to including all paths (
[*]) and excluding none ([]).
The configuration fields can be filled in two ways:
- Static filepaths: Enter the precise name of the file you are looking to include or exclude (for example,
docs/README.md). - Wildcard syntax: Use wildcards to match multiple paths. You can specify wildcards at the start or end of your rule.
For each path in a push event, build watch paths will be evaluated as follows:
- Paths satisfying excludes conditions are ignored first
- Any remaining paths are checked against includes conditions
- If any matching path is found, a build is triggered. Otherwise the build is skipped
Pages will bypass the path matching for a push event and default to building the project if:
- A push event contains 0 file changes, in case a user pushes an empty push event to trigger a build
- A push event contains 3000+ file changes or 20+ commits
To trigger a build only when files change within specific directories, such as project-a/ and packages/, use the following rules. Because * matches across path separators, this includes changes in nested subdirectories like project-a/src/index.js or packages/utils/lib/helpers.ts:
- Include paths:
project-a/*,packages/* - Exclude paths: (leave empty)
To trigger a build for any changes except those in a specific directory, such as docs/ (including nested paths like docs/guides/setup.md), use the following rules:
- Include paths:
* - Exclude paths:
docs/*
To trigger a build only when a specific file or filetype changes, such as any .md file in the repository, use the following rules:
- Include paths:
*.md - Exclude paths: (leave empty)
To trigger a build for changes in src/ while ignoring changes in src/tests/, use the following rules:
- Include paths:
src/* - Exclude paths:
src/tests/*