Skip to content

Commit cf617f0

Browse files
authored
[Workers] [Astro] Noindex value for specific pages (#19818)
1 parent 75d3818 commit cf617f0

File tree

7 files changed

+43
-37
lines changed

7 files changed

+43
-37
lines changed

src/components/overrides/Head.astro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ if (currentSection) {
144144
}
145145
}
146146
147+
// Add noindex tag if present in frontmatter
148+
149+
if (Astro.props.entry.data.noindex) {
150+
Astro.props.entry.data.head.push({
151+
tag: "meta",
152+
attrs: {
153+
name: "robots",
154+
content: "noindex",
155+
},
156+
content: "",
157+
});
158+
}
159+
147160
// Adding metadata used for reporting and search indexing
148161
// content type
149162
if (Astro.props.entry.data.pcx_content_type) {

src/content/docs/workers/configuration/sites/configuration.mdx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
pcx_content_type: configuration
33
title: Workers Sites configuration
4+
noindex: true
45
sidebar:
56
order: 4
6-
77
---
88

9-
import { Render, WranglerConfig } from "~/components"
9+
import { Render, WranglerConfig } from "~/components";
1010

1111
<Render file="workers_sites" />
1212

@@ -16,29 +16,23 @@ Workers Sites require the latest version of [Wrangler](https://github.com/cloudf
1616

1717
There are a few specific configuration settings for Workers Sites in your Wrangler file:
1818

19+
- `bucket` required
1920

21+
- The directory containing your static assets, path relative to your `wrangler.toml / wrangler.json` file. Example: `bucket = "./public"`.
2022

21-
* `bucket` required
22-
23-
* The directory containing your static assets, path relative to your `wrangler.toml / wrangler.json` file. Example: `bucket = "./public"`.
24-
25-
* `include` optional
26-
27-
* A list of gitignore-style patterns for files or directories in `bucket` you exclusively want to upload. Example: `include = ["upload_dir"]`.
28-
29-
* `exclude` optional
30-
* A list of gitignore-style patterns for files or directories in `bucket` you want to exclude from uploads. Example: `exclude = ["ignore_dir"]`.
23+
- `include` optional
3124

25+
- A list of gitignore-style patterns for files or directories in `bucket` you exclusively want to upload. Example: `include = ["upload_dir"]`.
3226

27+
- `exclude` optional
28+
- A list of gitignore-style patterns for files or directories in `bucket` you want to exclude from uploads. Example: `exclude = ["ignore_dir"]`.
3329

3430
To learn more about the optional `include` and `exclude` fields, refer to [Ignoring subsets of static assets](#ignoring-subsets-of-static-assets).
3531

3632
:::note
3733

38-
3934
If your project uses [environments](/workers/wrangler/environments/), make sure to place `site` above any environment-specific configuration blocks.
4035

41-
4236
:::
4337

4438
Example of a `wrangler.toml / wrangler.json` file:
@@ -80,8 +74,6 @@ This means that you should use gitignore semantics when declaring which director
8074

8175
If you want to include only a certain set of files or directories in your `bucket`, you can add an `include` field to your `[site]` section of your Wrangler file:
8276

83-
84-
8577
<WranglerConfig>
8678

8779
```toml
@@ -98,8 +90,6 @@ Wrangler will only upload files or directories matching the patterns in the `inc
9890

9991
If you want to exclude files or directories in your `bucket`, you can add an `exclude` field to your `[site]` section of your Wrangler file:
10092

101-
102-
10393
<WranglerConfig>
10494

10595
```toml
@@ -120,9 +110,9 @@ If you provide both `include` and `exclude` fields, the `include` field will be
120110

121111
Wrangler will always ignore:
122112

123-
* `node_modules`
124-
* Hidden files and directories
125-
* Symlinks
113+
- `node_modules`
114+
- Hidden files and directories
115+
- Symlinks
126116

127117
#### More about include/exclude patterns
128118

src/content/docs/workers/configuration/sites/index.mdx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,50 @@ pcx_content_type: navigation
33
title: Workers Sites
44
head: []
55
description: Use [Workers Static Assets](/workers/static-assets/) to host full-stack applications instead of Workers Sites. Do not use Workers Sites for new projects.
6+
noindex: true
67
---
78

8-
import { Render } from "~/components"
9-
import { LinkButton } from "~/components"
9+
import { Render } from "~/components";
10+
import { LinkButton } from "~/components";
1011

1112
<Render file="workers_sites" />
1213

1314
Workers Sites enables developers to deploy static applications directly to Workers. It can be used for deploying applications built with static site generators like [Hugo](https://gohugo.io) and [Gatsby](https://www.gatsbyjs.org), or front-end frameworks like [Vue](https://vuejs.org) and [React](https://reactjs.org).
1415

1516
To deploy with Workers Sites, select from one of these three approaches depending on the state of your target project:
1617

17-
***
18+
---
1819

1920
## 1. Start from scratch
2021

2122
If you are ready to start a brand new project, this quick start guide will help you set up the infrastructure to deploy a HTML website to Workers.
2223

23-
<LinkButton href="/workers/configuration/sites/start-from-scratch/">Start from scratch</LinkButton>
24+
<LinkButton href="/workers/configuration/sites/start-from-scratch/">
25+
Start from scratch
26+
</LinkButton>
2427

25-
***
28+
---
2629

2730
## 2. Deploy an existing static site
2831

2932
If you have an existing project or static assets that you want to deploy with Workers, this quick start guide will help you install Wrangler and configure Workers Sites for your project.
3033

31-
<LinkButton href="/workers/configuration/sites/start-from-existing/">Start from an existing static site</LinkButton>
34+
<LinkButton href="/workers/configuration/sites/start-from-existing/">
35+
Start from an existing static site
36+
</LinkButton>
3237

33-
***
38+
---
3439

3540
## 3. Add static assets to an existing Workers project
3641

3742
If you already have a Worker deployed to Cloudflare, this quick start guide will show you how to configure the existing codebase to use Workers Sites.
3843

39-
<LinkButton href="/workers/configuration/sites/start-from-worker/">Start from an existing Worker</LinkButton>
44+
<LinkButton href="/workers/configuration/sites/start-from-worker/">
45+
Start from an existing Worker
46+
</LinkButton>
4047

4148
:::note
4249

43-
4450
Workers Sites is built on Workers KV, and usage rates may apply. Refer to [Pricing](/workers/platform/pricing/) to learn more.
4551

46-
4752
:::

src/content/docs/workers/configuration/sites/start-from-existing.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Start from existing
4+
noindex: true
45
sidebar:
56
order: 1
67
---
@@ -126,8 +127,6 @@ async function handleEvent(event) {
126127

127128
6. Deploy your site to a [custom domain](/workers/configuration/routing/custom-domains/) that you own and have already attached as a Cloudflare zone. Add a `route` property to the Wrangler file.
128129

129-
130-
131130
<WranglerConfig>
132131

133132
```toml

src/content/docs/workers/configuration/sites/start-from-scratch.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Start from scratch
4+
noindex: true
45
sidebar:
56
order: 2
67
---
@@ -60,8 +61,6 @@ The template project contains the following files and directories:
6061

6162
- Consider updating`compatibility_date` to today's date to get access to the most recent Workers features:
6263

63-
64-
6564
<WranglerConfig>
6665

6766
```toml
@@ -72,8 +71,6 @@ The template project contains the following files and directories:
7271

7372
- Deploy your site to a [custom domain](/workers/configuration/routing/custom-domains/) that you own and have already attached as a Cloudflare zone:
7473

75-
76-
7774
<WranglerConfig>
7875

7976
```toml

src/content/docs/workers/configuration/sites/start-from-worker.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Start from Worker
4+
noindex: true
45
sidebar:
56
order: 3
67
---

src/schemas/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const baseSchema = z.object({
7373
summary: z.string().optional(),
7474
goal: z.string().array().optional(),
7575
operation: z.string().array().optional(),
76+
noindex: z.boolean().optional(),
7677
sidebar: z
7778
.object({
7879
order: z.number().optional(),

0 commit comments

Comments
 (0)