Skip to content

Commit bd8d6cc

Browse files
committed
migrated over info on redirects
1 parent e70f243 commit bd8d6cc

File tree

9 files changed

+204
-123
lines changed

9 files changed

+204
-123
lines changed

public/__redirects

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,12 @@
13121312
/stream/platform/ /stream/changelog/ 301
13131313
/stream/reference/ /stream/faq/ 301
13141314

1315+
# style guide
1316+
1317+
/docs-guide/manage-content/redirects/ /style-guide/how-we-docs/redirects/ 301
1318+
/docs-guide/manage-content/redirects/best-practices/ /style-guide/how-we-docs/redirects/ 301
1319+
/docs-guide/manage-content/redirects/process/ /style-guide/how-we-docs/redirects/ 301
1320+
13151321
# support
13161322

13171323
/support/about-cloudflare/getting-started/troubleshooting-faq-for-new-cloudflare-customers/ /fundamentals/reference/troubleshooting/ 301

src/content/docs/docs-guide/manage-content/redirects/best-practices.mdx

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/content/docs/docs-guide/manage-content/redirects/index.mdx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/content/docs/docs-guide/manage-content/redirects/process.mdx

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
---
22
pcx_content_type: concept
33
title: Links
4-
4+
meta:
5+
title: Links | Component attributes
56
---
67

7-
## Definition
8-
9-
Reference to data that can be accessed by clicking, tapping, or selecting.
8+
import { Render } from "~/components";
109

11-
## Used in
10+
A link is a reference to another page, part of a page, or external resource.
1211

13-
All content types
12+
Hyperlinks are incredibly useful but - if overdone - can be distracting.
1413

15-
## Overview
14+
## Types of links
1615

17-
Hyperlinks are incredibly useful in online content but should not be overdone. Excessive hyperlinking inside of paragraphs is often distracting and can deviate the reader's focus from the piece at hand.
16+
<Render file="link-types" />
1817

1918
## Guidance for inline paragraph links
2019

21-
Avoid non-descriptive link text like: click here and this page; instead, use the actual title of the target page or an abbreviated version of that title. This is also important so that readers see that when they get there, they actually linked to the page they intended to visit.
20+
Avoid non-descriptive link text like: `click here` and `this page`; instead, use the actual title of the target page or an abbreviated version of that title. This is also important so that readers see that when they get there, they actually linked to the page they intended to visit.
2221

2322
Use unique link text. Speech recognition software does not handle duplicated link text well.
2423

25-
Use in-paragraph links only if they are internal (those within Cloudflare's websites) and if the material relates directly to what's being described. In other words, will the content behind the link help the reader make a decision or accomplish something before continuing to read the current document?
24+
Use in-paragraph links only if they are internal (those within Cloudflare's websites) and if the material relates directly to what's being described. In other words, will the content behind the link help the reader make a decision or accomplish something before continuing to read the current document?
2625

2726
Avoid directional language.
2827

2928
## Links for the Related resources section
3029

31-
Use a *Related resources* section at the end of your document for:
30+
Use a _Related resources_ section at the end of your document for:
3231

33-
* Internal links that loosely relate to the topic or offer a chance for deeper learning
34-
* All external links (not residing in Cloudflare's websites)
35-
* Internal and external links that represent the next logical steps to follow
32+
- Internal links that loosely relate to the topic or offer a chance for deeper learning
33+
- All external links (not residing in Cloudflare's websites)
34+
- Internal and external links that represent the next logical steps to follow
3635

3736
External links placed in-paragraph are strongly discouraged because Cloudflare has no control over them. For example, if a link no longer resolves, our content feels less reliable. By shifting all external links to the end of the document, the impact of a broken link is less dramatic.
3837

@@ -42,6 +41,10 @@ Place links for example requests and API calls in code blocks.
4241

4342
Use placeholders in links with account- or user-specific information. And explain what to replace the referential text with.
4443

45-
* For example, for the link "`https://api.cloudflare.com/client/v4/accounts/a0b1c2d3/rulesets`" use "`https://api.cloudflare.com/client/v4/accounts/<ACCOUNTID>/rulesets`" and add text to say "replace `<ACCOUNTID>` with your Account ID" or similar.
44+
- For example, for the link "`https://api.cloudflare.com/client/v4/accounts/a0b1c2d3/rulesets`" use "`https://api.cloudflare.com/client/v4/accounts/<ACCOUNTID>/rulesets`" and add text to say "replace `<ACCOUNTID>` with your Account ID" or similar.
4645

4746
See [angle brackets](/style-guide/formatting/code-conventions-and-format/) in Code Conventions and Formatting.
47+
48+
## Maintenance
49+
50+
For more details on how we handle link maintenance, refer to [Link maintenance](/style-guide/how-we-docs/links/).

src/content/docs/style-guide/how-we-docs/links.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,59 @@ title: Links
44
meta:
55
title: Links | How we docs
66
---
7+
8+
import { Render } from "~/components";
9+
10+
Though [links](/style-guide/documentation-content-strategy/component-attributes/links/) are an important part of documentation, they also have their own maintenance cost.
11+
12+
We have a few strategies we use to make link maintenance easier.
13+
14+
## Link types
15+
16+
<Render file="link-types" />
17+
18+
For each type of link, we think through a few different aspects of the experience.
19+
20+
- **External**:
21+
- _Source of truth_: Another site.
22+
- _Why does it break_: Another site changed its content.
23+
- _Customer experience of a break_: `404` page on another site.
24+
- **Internal**:
25+
- _Source of truth_: Your site.
26+
- _Why does it break_: Your site changed its content.
27+
- _Customer experience of a break_: `404` page on your site.
28+
- **Anchor**:
29+
- _Source of truth_: Your site.
30+
- _Why does it break_: Your site changed its content.
31+
- _Customer experience of a break_: Page load on your site. Content might be further down the page or have been moved to another page.
32+
33+
## Checks
34+
35+
### Internal links
36+
37+
Of these three [link types](#link-types), only **Internal** links:
38+
39+
- Happen _within_ the context of a change to your site's content.
40+
- Universally lead to a bad customer experience (a `404` page).
41+
- Are easily auditable within the current context.
42+
43+
For these reasons, we choose to **fail** a build based on broken internal links. For our implementation, we rely on the Starlight link validator plugin.
44+
45+
{/* Insert reference to astro.config.ts + links to starlight link plugin + CI build step */}
46+
47+
We also make two intentional decisions about this link auditing:
48+
49+
- **Absolute links, not relative**: We enforce absolute links (`/style-guide/how-we-docs/metadata/`) and fail on relative links (`../metadata/`) to avoid time-consuming maintenance in the future. This decision also helps with find/replace work and any future platform migrations.
50+
- **No redirects**: We do not consider redirects when evaluating links. We have the current source of truth, so we should utilize that truth to its fullest (as well as helping us avoid redirect chains and future maintenance).
51+
52+
### External links
53+
54+
Though external links are not good for the customer experience, they also don't change within the context of a change to your site's content. Additionally, external link checking can be time consuming and error prone, which can slow down contributions.
55+
56+
We use an external SEO tool to help flag these broken external links for us, addressing them as needed (instead of failing a build on them).
57+
58+
### Anchor links
59+
60+
Anchor links do not have as dramatic as consequences of being wrong as internal links. If you have a broken anchor link, a customer will either need to manually scroll to the header or - in some cases - go to another page.
61+
62+
Because of these characteristics, we run periodic, background checks to flag broken anchor links, using the `htmltest` library.

src/content/docs/style-guide/how-we-docs/metadata.mdx

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/content/docs/style-guide/how-we-docs/redirects.mdx

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,118 @@ title: Redirects
44
meta:
55
title: Redirects | How we docs
66
---
7+
8+
import { GlossaryTooltip } from "~/components";
9+
10+
As your content changes (and it will change), <GlossaryTooltip term="redirect">redirects</GlossaryTooltip> preserve continuity for your users and (friendly) bots.
11+
12+
The most obvious part of this is the user experience. If you click a link in the dashboard or use a bookmarked URL, you trust that it's taking you to the right place. Not a `404` page or the wrong page, but the right page. Redirects help direct users to the right place.
13+
14+
The same applies to the automated experience. If you move a page without redirects, you are losing the historical search authority that Google and other search engines use to rank your page.
15+
16+
---
17+
18+
## How we add redirects
19+
20+
### Cloudflare Workers (primary)
21+
22+
Our primary method takes advantage of [Workers Static Assets](/workers/static-assets/redirects/), defining redirects in a [plain text file](https://github.com/cloudflare/cloudflare-docs/blob/production/public/__redirects) in our GitHub repo.
23+
24+
This setup allows us to use the same workflow for redirects as for any other documentation change. We implement a redirect in the same pull request as the content change and can test these changes in our preview branches. For maintenance, we try to keep these redirects [organized](#organize-your-redirects) by product and then — within each product — organized alphabetically.
25+
26+
We also love the flexibility provided by the [Pages syntax](/workers/static-assets/redirects/#advanced-redirects).
27+
28+
### Bulk redirects (secondary)
29+
30+
In certain situations, we also use [Bulk redirects](/rules/url-forwarding/bulk-redirects/). We use this strategy sparing because having redirects in multiple places increases the cognitive load and potential confusion of making a change.
31+
32+
Normally, bulk redirects only come up when another team is adding a large number of individual redirects to our site, such as when all of our previous `support.cloudflare.com` content was migrated and needed individualized redirects per locale.
33+
34+
We use this method when the contributors are outside of our team and when the total number of redirects is so large that it would clutter our `__redirects` file and count against our [limit for redirects](/workers/static-assets/redirects/#surpass-_redirects-limits).
35+
36+
---
37+
38+
## When we add redirects
39+
40+
Our team adds redirects in two situations: during the course of normal content and as needed based on data.
41+
42+
### During content work
43+
44+
During normal content work, you want to add redirects when you do the following to a page:
45+
46+
- Change any part of the URL (filename, folder).
47+
- Delete the page.
48+
49+
We have some automation to help [flag needed redirects](#potential-redirects).
50+
51+
### Based on data
52+
53+
Another time to add redirects is when you see a lot of `404` response codes on certain paths of your docs site. These `404` responses might be due to a missing redirect or mistyped link.
54+
55+
We identify these status codes either through our [Cloudflare analytics](/analytics/account-and-zone-analytics/zone-analytics/) (ad hoc) or [Logpush job](/logs/about/) (more thorough, quarterly).
56+
57+
---
58+
59+
## How we automate redirects
60+
61+
We have two automations in GitHub to help with redirects.
62+
63+
### Infinite redirects
64+
65+
An infinite redirect is when two pages keep redirecting to each other, trapping users in an infitnite loop that will crash their browser.
66+
67+
Because that’s just a terrible experience, we explicitly check for that as part of our required `CI` GitHub action.
68+
69+
{/* {{ CI step — use GitHub code }} */}
70+
71+
We trigger this check _after_ we build our site. What it does it then call this script.
72+
73+
{/* {{ Infinite redirects — use GitHub code }} */}
74+
75+
{/* Talk through details of the script. */}
76+
77+
### Potential redirects
78+
79+
Contributors often struggle to know when they should add redirects. We try to help them by adding a comment to any pull requests that modify or delete content file paths.
80+
81+
{/* Insert picture of comment */}
82+
83+
{/* Talk through script */}
84+
85+
---
86+
87+
## Other guidance
88+
89+
### Organize your redirects
90+
91+
As much as you can, try to organize your redirects into logical groups (products, alphabetical order). This process helps prevent duplicate redirects, as well as identifying specific ones you might be looking for.
92+
93+
In our [`__redirects` file](https://github.com/cloudflare/cloudflare-docs/blob/production/public/__redirects), we use extensive comments, separating different product areas. We also try, as much as we can, to keep the redirects in alphabetical order within a section.
94+
95+
We used to apply a similar principle to [Bulk Redirect lists](/rules/url-forwarding/bulk-redirects/) (when that was our primary method). We created lists that grouped together similar products and labeled them as such, so it was easier to find which redirect you were looking for.
96+
97+
### Know what you can redirect
98+
99+
At the server level, you can trigger a redirect on a URL path (`/page/`), but not a fragment (`/page/#fragment`).
100+
101+
You can redirect a page to a fragment, however (`/page1/` to `/page2/#fragment`).
102+
103+
### Avoid redirect chains
104+
105+
If possible, have all redirects send your users directly to their destination instead of chaining together redirects.
106+
107+
Otherwise, you can have the following situation:
108+
109+
```txt
110+
Page 1 --Redirect-> Page 2 --Redirect-> Page 3 --Redirect-> Page 4
111+
```
112+
113+
A way to avoid this outcome is by continually updating the destinations of previous redirects. For example, let's say you changed the name of this page to `/style-guide/how-we-docs/redirect-guidance/`.
114+
115+
In the pull request to update your redirects file, you would want to update the existing redirect as well as adding a new redirect:
116+
117+
```diff title="__redirects"
118+
- /style-guide/redirects/ /style-guide/how-we-docs/redirects/ 301
119+
+ /style-guide/redirects/ /style-guide/how-we-docs/redirect-guidance/ 301
120+
+ /style-guide/how-we-docs/redirects/ /style-guide/how-we-docs/redirect-guidance/ 301
121+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
{}
3+
---
4+
5+
There are 3 types of links:
6+
7+
- **External**: To other resources, such as www.cloudflare.com.
8+
- **Internal**: To other pages in the docs, such as [Workers](/workers/).
9+
- **Anchor**: To specific parts of other pages in our docs, such as [Proxied records](/dns/proxy-status/#proxied-records).

0 commit comments

Comments
 (0)