Pages Deployment
Deploying static sites with wrangler pages deploy
Creating a Pages Project
Before your first deploy, create the project:
npx wrangler@4 pages project create zudo-cloudflareOr let the first pages deploy create it automatically.
Deploy Command
The core deploy command:
npx wrangler@4 pages deploy <directory> \
--project-name=<project-name> \
--branch=<branch> \
--commit-hash="${GITHUB_SHA}" \
--commit-message="Production deploy: ${GITHUB_SHA}"Parameters
| Parameter | Description |
|---|---|
<directory> | The directory containing built static files |
--project-name | The Pages project name (must match what was created) |
--branch | Branch name. main triggers production; anything else is a preview |
--commit-hash | Git SHA for tracking (optional but recommended) |
--commit-message | Deploy description (optional) |
Environment Variables
The deploy command needs these environment variables:
CLOUDFLARE_API_TOKEN=<your-token>
CLOUDFLARE_ACCOUNT_ID=<your-account-id>Production vs Preview
Production: Deploy with
--branch=main. This updates the primary URL.Preview: Deploy with any other branch name (e.g.,
--branch=pr-42). This creates a preview URL.
Warning
The --branch flag determines whether the deploy is production or preview. Always use main for production deploys, not your actual branch name.
Deploy Directory Structure
The deploy directory must contain the final files as they should be served. If your site uses a base path (e.g., /), you need to nest files accordingly:
mkdir -p deploy/pj/my-site
cp -r dist/* deploy/pj/my-site/
echo '/ /pj/my-site/ 302' > deploy/_redirects
npx wrangler@4 pages deploy deploy --project-name=my-site --branch=mainSee Base Path Pattern for details.
Revision History
Takeshi TakatsudoCreated: 2026-04-04T22:50:44+09:00Updated: 2026-04-04T22:50:44+09:00