Skip to content

Commit 9b91749

Browse files
docs: add documentation for wrangler pages deployment delete command
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
1 parent 21d27c0 commit 9b91749

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/content/docs/pages/configuration/api.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ After you have deployed the JavaScript Worker, set a cron trigger in your Worker
6464

6565
Cloudflare Pages hosts and serves all project deployments on preview links. Suppose you want to keep your project private and prevent access to your old deployments. You can use the API to delete deployments after a month, so that they are no longer public online. The latest deployment for a branch cannot be deleted.
6666

67+
:::note
68+
To delete individual deployments from the command line, you can use [`wrangler pages deployment delete`](/workers/wrangler/commands/#deployment-delete).
69+
:::
70+
6771
```js
6872
const endpoint =
6973
"https://api.cloudflare.com/client/v4/accounts/{account_id}/pages/projects/{project_name}/deployments";

src/content/docs/pages/configuration/preview-deployments.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ To view branch aliases within your Pages project, select **View build** for any
7070

7171
You can attach a Preview alias to a custom domain by [adding a custom domain to a branch](https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/).
7272

73+
## Delete preview deployments
74+
75+
To clean up old preview deployments, you can delete them using Wrangler:
76+
77+
```sh
78+
npx wrangler pages deployment delete <DEPLOYMENT_ID> --project-name <PROJECT_NAME>
79+
```
80+
81+
Use the `--force` (or `-f`) flag to skip the confirmation prompt, which is useful for CI/CD automation. You can find deployment IDs by running [`wrangler pages deployment list`](/workers/wrangler/commands/#deployment-list).
82+
83+
:::note
84+
The latest deployment for a branch cannot be deleted.
85+
:::
86+
7387
## Preview indexing by search engines
7488

7589
To maintain a healthy SEO profile, it's vital to prevent search engines from finding duplicate content across the web. Because preview deployments are designed to be an exact replica of your production environment, they inherently create this exact situation. Cloudflare Pages by default ensures your search rankings are not harmed by these temporary previews.

src/content/docs/pages/platform/known-issues.mdx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,13 @@ If you have an issue that you do not see listed, let the team know in the Cloudf
9595

9696
You may not be able to delete your Pages project if it has a high number (over 100) of deployments. The Cloudflare team is tracking this issue.
9797

98-
As a workaround, review the following steps to delete all deployments in your Pages project. After you delete your deployments, you will be able to delete your Pages project.
99-
100-
1. Download the `delete-all-deployments.zip` file by going to the following link: [https://pub-505c82ba1c844ba788b97b1ed9415e75.r2.dev/delete-all-deployments.zip](https://pub-505c82ba1c844ba788b97b1ed9415e75.r2.dev/delete-all-deployments.zip).
101-
2. Extract the `delete-all-deployments.zip` file.
102-
3. Open your terminal and `cd` into the `delete-all-deployments` directory.
103-
4. In the `delete-all-deployments` directory, run `npm install` to install dependencies.
104-
5. Review the following commands to decide which deletion you would like to proceed with:
105-
106-
- To delete all deployments except for the live production deployment (excluding [aliased deployments](https://developers.cloudflare.com/pages/configuration/preview-deployments/#preview-aliases)):
107-
108-
```sh
109-
CF_API_TOKEN=<YOUR_CF_API_TOKEN> CF_ACCOUNT_ID=<ACCOUNT_ID> CF_PAGES_PROJECT_NAME=<PROJECT_NAME> npm start
110-
```
111-
112-
- To delete all deployments except for the live production deployment (including [aliased deployments](https://developers.cloudflare.com/pages/configuration/preview-deployments/#preview-aliases), for example, `staging.example.pages.dev`):
98+
As a workaround, you can use [`wrangler pages deployment delete`](/workers/wrangler/commands/#deployment-delete) to delete deployments individually. After you delete your deployments, you will be able to delete your Pages project.
11399

114100
```sh
115-
CF_API_TOKEN=<YOUR_CF_API_TOKEN> CF_ACCOUNT_ID=<ACCOUNT_ID> CF_PAGES_PROJECT_NAME=<PROJECT_NAME> CF_DELETE_ALIASED_DEPLOYMENTS=true npm start
101+
npx wrangler pages deployment delete <DEPLOYMENT_ID> --project-name <PROJECT_NAME>
116102
```
117103

118-
To find your Cloudflare API token, log in to the [Cloudflare dashboard](https://dash.cloudflare.com), select the user icon on the upper righthand side of your screen > go to **My Profile** > **API Tokens**.
119-
120-
You need a token with `Cloudflare Pages Edit` permissions.
121-
122-
To find your Account ID, refer to [Find your zone and account ID](/fundamentals/account/find-account-and-zone-ids/).
104+
Use the `--force` flag to skip the confirmation prompt, which is useful for scripting bulk deletions.
123105

124106
## Use Pages as Origin in Cloudflare Load Balancer
125107

0 commit comments

Comments
 (0)