You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
6
+
type: note
7
+
dismissible:
8
+
id: pages-migrate-to-workers
5
9
---
6
10
7
11
The [Pages API](/api/resources/pages/subresources/projects/methods/list/) empowers you to build automations and integrate Pages with your development workflow. At a high level, the API endpoints let you manage deployments and builds and configure projects. Cloudflare supports [Deploy Hooks](/pages/configuration/deploy-hooks/) for headless CMS deployments. Refer to the [API documentation](https://api.cloudflare.com/) for a full breakdown of object types and endpoints.
@@ -37,22 +41,23 @@ The API is even more powerful when combined with Cloudflare Workers: the easiest
37
41
Suppose we have a CMS that pulls data from live sources to compile a static output. You can keep the static content as recent as possible by triggering new builds periodically using the API.
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
49
-
"Authorization":`Bearer ${env.API_TOKEN}`,
50
-
},
51
-
};
52
-
53
-
awaitfetch(endpoint, init);
54
-
}
55
-
}
48
+
asyncscheduled(_, env) {
49
+
constinit= {
50
+
method:"POST",
51
+
headers: {
52
+
"Content-Type":"application/json;charset=UTF-8",
53
+
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
54
+
Authorization:`Bearer ${env.API_TOKEN}`,
55
+
},
56
+
};
57
+
58
+
awaitfetch(endpoint, init);
59
+
},
60
+
};
56
61
```
57
62
58
63
After you have deployed the JavaScript Worker, set a cron trigger in your Worker to run this script periodically. Refer to [Cron Triggers](/workers/configuration/cron-triggers/) for more details.
@@ -62,37 +67,41 @@ After you have deployed the JavaScript Worker, set a cron trigger in your Worker
62
67
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.
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
74
-
"Authorization":`Bearer ${env.API_TOKEN}`,
75
-
},
76
-
};
77
-
78
-
constresponse=awaitfetch(endpoint, init);
79
-
constdeployments=awaitresponse.json();
80
-
81
-
for (constdeploymentofdeployments.result) {
82
-
// Check if the deployment was created within the last x days (as defined by `expirationDays` above)
83
-
if ((Date.now() -newDate(deployment.created_on)) /86400000> expirationDays) {
84
-
// Delete the deployment
85
-
awaitfetch(`${endpoint}/${deployment.id}`, {
86
-
method:"DELETE",
87
-
headers: {
88
-
"Content-Type":"application/json;charset=UTF-8",
89
-
"Authorization":`Bearer ${env.API_TOKEN}`,
90
-
},
91
-
});
92
-
}
93
-
}
94
-
}
95
-
}
75
+
asyncscheduled(_, env) {
76
+
constinit= {
77
+
headers: {
78
+
"Content-Type":"application/json;charset=UTF-8",
79
+
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
80
+
Authorization:`Bearer ${env.API_TOKEN}`,
81
+
},
82
+
};
83
+
84
+
constresponse=awaitfetch(endpoint, init);
85
+
constdeployments=awaitresponse.json();
86
+
87
+
for (constdeploymentofdeployments.result) {
88
+
// Check if the deployment was created within the last x days (as defined by `expirationDays` above)
After you have deployed the JavaScript Worker, you can set a cron trigger in your Worker to run this script periodically. Refer to the [Cron Triggers guide](/workers/configuration/cron-triggers/) for more details.
@@ -103,40 +112,40 @@ Imagine you are working on a development team using Pages to build your websites
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
// We recommend you store the API token as a secret using the Workers dashboard or using Wrangler as documented here: https://developers.cloudflare.com/workers/wrangler/commands/#secret
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
6
+
type: note
7
+
dismissible:
8
+
id: pages-migrate-to-workers
5
9
---
6
10
7
-
import { Render } from"~/components"
11
+
import { Render } from"~/components";
8
12
9
13
When connected to your git repository, Pages allows you to control which environments and branches you would like to automatically deploy to. By default, Pages will trigger a deployment any time you commit to either your production or preview environment. However, with branch deployment controls, you can configure automatic deployments to suit your preference on a per project basis.
10
14
11
15
## Production branch control
12
16
13
17
:::caution[Direct Upload]
14
18
15
-
16
19
<Renderfile="prod-branch-update" />
17
20
18
-
19
21
:::
20
22
21
23
To configure deployment options, go to your Pages project > **Settings** > **Builds & deployments** > **Configure Production deployments**. Pages will default to setting your production environment to the branch you first push, but you can set your production to another branch if you choose.
@@ -26,33 +28,31 @@ You can also enable or disable automatic deployment behavior on the production b
26
28
27
29
When configuring automatic preview deployments, there are three options to choose from.
28
30
29
-
***All non-Production branches**: By default, Pages will automatically deploy any and every commit to a preview branch.
30
-
***None**: Turns off automatic builds for all preview branches.
31
-
***Custom branches**: Customize the automatic deployments of certain preview branches.
31
+
-**All non-Production branches**: By default, Pages will automatically deploy any and every commit to a preview branch.
32
+
-**None**: Turns off automatic builds for all preview branches.
33
+
-**Custom branches**: Customize the automatic deployments of certain preview branches.
32
34
33
35
### Custom preview branch control
34
36
35
37
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:
36
38
37
-
***Static branch names**: Enter the precise name of the branch you are looking to include or exclude (for example, staging or dev).
38
-
***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.
39
+
-**Static branch names**: Enter the precise name of the branch you are looking to include or exclude (for example, staging or dev).
40
+
-**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.
39
41
40
42
:::note[Wildcard syntax]
41
43
42
-
43
44
A wildcard (`*`) is a character that is used within rules. It can be placed alone to match anything or placed at the start or end of a rule to allow for better control over branch configuration. A wildcard will match zero or more characters.For example, if you wanted to match all branches that started with `fix/` then you would create the rule `fix/*` to match strings like `fix/1`, `fix/bugs`or `fix/`.
44
45
45
-
46
46
:::
47
47
48
48
**Example 1:**
49
49
50
50
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:
51
51
52
-
* Include Preview branches:
52
+
- Include Preview branches:
53
53
`fix/*`, `feat/*`, `chore/*`
54
54
55
-
* Exclude Preview branches:
55
+
- Exclude Preview branches:
56
56
\`\`
57
57
58
58
Here Pages will include any branches with the indicated prefixes and exclude everything else. In this example, the excluding option is left empty.
@@ -61,22 +61,22 @@ Here Pages will include any branches with the indicated prefixes and exclude eve
61
61
62
62
If you wanted to prevent [dependabot](https://github.com/dependabot) from creating a deployment for each PR it creates, you can exclude those branches with the following:
63
63
64
-
* Include Preview branches:
64
+
- Include Preview branches:
65
65
`*`
66
66
67
-
* Exclude Preview branches:
67
+
- Exclude Preview branches:
68
68
`dependabot/*`
69
69
70
-
Here Pages will include all branches except any branch starting with `dependabot`. In this example, the excluding option means any `dependabot/`branches will not be built.
70
+
Here Pages will include all branches except any branch starting with `dependabot`. In this example, the excluding option means any `dependabot/` branches will not be built.
71
71
72
72
**Example 3:**
73
73
74
74
If you only want to deploy release-prefixed branches, then you could use the following rules:
75
75
76
-
* Include Preview branches:
76
+
- Include Preview branches:
77
77
`release/*`
78
78
79
-
* Exclude Preview branches:
79
+
- Exclude Preview branches:
80
80
`*`
81
81
82
82
This will deploy only branches starting with `release/`.
Copy file name to clipboardExpand all lines: src/content/docs/pages/configuration/build-caching.mdx
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
1
---
2
2
pcx_content_type: concept
3
3
title: Build caching
4
+
banner:
5
+
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
6
+
type: note
7
+
dismissible:
8
+
id: pages-migrate-to-workers
4
9
---
5
10
6
11
Improve Pages build times by caching dependencies and build output between builds with a project-wide shared cache.
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
Copy file name to clipboardExpand all lines: src/content/docs/pages/configuration/build-watch-paths.mdx
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
1
---
2
2
pcx_content_type: concept
3
3
title: Build watch paths
4
+
banner:
5
+
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
6
+
type: note
7
+
dismissible:
8
+
id: pages-migrate-to-workers
4
9
---
5
10
6
11
When you connect a git repository to Pages, by default a change to any file in the repository will trigger a Pages build. You can configure Pages to include or exclude specific paths to specify if Pages should skip a build for a given path. This can be especially helpful if you are using a monorepo project structure and want to limit the amount of builds being kicked off.
Copy file name to clipboardExpand all lines: src/content/docs/pages/configuration/custom-domains.mdx
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
1
---
2
2
pcx_content_type: how-to
3
3
title: Custom domains
4
+
banner:
5
+
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
Copy file name to clipboardExpand all lines: src/content/docs/pages/configuration/debugging-pages.mdx
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
1
---
2
2
pcx_content_type: how-to
3
3
title: Debugging Pages
4
+
banner:
5
+
content: We recommend using <strong>Cloudflare Workers</strong> for new projects. For existing Pages projects, see our <a href="/workers/static-assets/migrate-from-pages/">migration guide</a> and <a href="/workers/static-assets/migrate-from-pages/#compatibility-matrix">compatibility matrix</a>.
6
+
type: note
7
+
dismissible:
8
+
id: pages-migrate-to-workers
4
9
---
5
10
6
11
When setting up your Pages project, you may encounter various errors that prevent you from successfully deploying your site. This guide gives an overview of some common errors and solutions.
0 commit comments