Skip to content

Commit a7c4d60

Browse files
#795 Update README w navigation and moving/renaming file info (#820)
* Added page about moving/renaming docs, new headings for readme * added navigation section * revised README * revised moving-or-renaming-docs * Apply suggestions from code review Co-authored-by: Lucas Saintarbor <[email protected]> * Update moving-or-renaming-docs.md - revamping schema example * json > js * typos, extra explanation * json > js * various changes --------- Co-authored-by: Lucas Saintarbor <[email protected]>
1 parent 6c332ea commit a7c4d60

File tree

2 files changed

+88
-6
lines changed

2 files changed

+88
-6
lines changed

README.md

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
1-
# Edit The Docs
1+
# Contribute to Rancher Docs
22

3-
To get started, fork and clone the rancher-docs repository.
3+
Welcome to the [Rancher docs](https://ranchermanager.docs.rancher.com/) repository. See the [Rancher software](https://github.com/rancher/rancher) repository if you have questions or requests for the Rancher platform.
4+
5+
## Make a Suggestion
6+
7+
You can suggest changes to the Rancher docs in two ways:
8+
9+
1. [Open an issue](https://github.com/rancher/rancher-docs/issues/new/choose).
10+
1. Edit the docs in the way you see fit and open a pull request.
11+
12+
## Edit the Docs
13+
14+
To get started, [fork](https://github.com/rancher/rancher-docs/fork) and clone the rancher-docs repository.
415

516
Our repository doesn't allow you to make changes directly to the `main` branch. Create a working branch and make pull requests from your fork to [rancher/rancher-docs](https://github.com/rancher/rancher-docs).
617

718
For most updates, you'll need to edit a file in `/docs`, and the corresponding file in `/versioned_docs/version-2.7`. If a change affects older versions, you can find files documenting Rancher v2.0 and later in the `/versioned_docs` directory.
819

9-
If a file is moved or renamed, you'll also need to edit the `sidebars.js` files for each version, and the list of redirects in `docusaurus.config.js`.
20+
If a file is moved or renamed, you'll also need to edit the `sidebars.js` files for each version, and the list of redirects in `docusaurus.config.js`. See [Moving or Renaming Docs](./moving-or-renaming-docs.md).
21+
22+
### Navigate the Repo
23+
24+
The file paths in the repo correspond to the URLs for pages on the docs website. The docs for the latest version of Rancher are located in `/docs`. Most index pages are found within the `/pages-for-subheaders` directory in `/docs`. All images are in `/static/img` in the top level of the repo. Older docs are found within `/versioned_docs` and generally follow the same structure as the files in `/docs`.
1025

11-
## Style & Formatting
26+
### Style & Formatting
1227

13-
The docs are written in [Markdown](https://www.markdownguide.org/getting-started/). We refer to the Microsoft [style guide](https://learn.microsoft.com/en-us/style-guide/welcome/) and generally use standard American English. Many pages are also available in Simplified Chinese.
28+
The docs are written in [Markdown](https://www.markdownguide.org/getting-started/). We refer to the Microsoft [style guide](https://learn.microsoft.com/en-us/style-guide/welcome/) and use standard American English. Many pages are also available in Simplified Chinese.
1429

1530
Every docs page contain metadata in the first few lines:
1631

@@ -22,7 +37,7 @@ title: Some Title
2237

2338
The `title` is rendered as the page's headline. The site renderer wraps the `title` value in `H1` tags, which are equivalent to `#` in Markdown syntax. This means that all subsequent headers on the page should be second level (`##`) or more.
2439

25-
## Docs Website
40+
## Run the Docs Website
2641

2742
The Rancher Docs website is built with [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
2843

moving-or-renaming-docs.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Adding, Moving, or Renaming Docs
2+
3+
Docusaurus generates sidebars based on a JSON file named `sidebars.js`. When you add a new doc, you need to add an entry to `sidebars.js`. Otherwise, the page won't appear in the list of sidebar topics. When you move or re-title a doc, you need to update `sidebars.js` to reflect the change to the doc's location or title. If you alter a docs file's path, by moving the file or editing the file's name, you'll also need to add a redirect to the new path in `docusaurus.config.js`.
4+
5+
> **Note:** Avoid adding filenames that contain periods before the file extension (example: `rke2-self-assessment-guide-with-cis-v1.23-k8s-v1.25.md`). If necessary, use dashes instead of periods (`rke2-self-assessment-guide-with-cis-v1-23-k8s-v1-25.md`).
6+
7+
## Sidebars
8+
9+
The `sidebars.js` file for the latest version of Rancher is located in the top level of the repo. Versioned docs each have their own versioned sidebar, found within `/versioned_sidebars` in the top level of the repo.
10+
11+
The schema for `sidebars.js` looks like this:
12+
13+
```JS
14+
sidebar: [
15+
"toplevel",
16+
{
17+
type: "category",
18+
label: "Second Level",
19+
items: [
20+
"second-level/overview",
21+
{
22+
type: "category",
23+
label: "Topic One",
24+
link: {
25+
type: "doc",
26+
id: "pages-for-subheaders/index-page-for-topic-one"
27+
}
28+
items: [
29+
"second-level/topic-one/page-a",
30+
"second-level/topic-one/page-b",
31+
]
32+
}
33+
]
34+
}
35+
]
36+
```
37+
38+
Paths for docs files are listed within an `items` array. Their position within the file is similar to how they'll be organized within the published sidebar.
39+
40+
If the doc is as an index page for a topic with numerous subtopic pages, its entry in `sidebars.js` should have extra metadata, such as `category`, `link`, and `label`.
41+
42+
### Moving Index Pages
43+
44+
Some entries in the published sidebar are clickable dropdown menus. When a reader clicks them, they reveal a list of subtopics. These dropdown menu entries are indicated by `type: category` in the sidebar file. When you select the entry on the published docs site, the menu opens and you will navigate to the page indicated in `link.id`.
45+
46+
Docusaurus uses the `label` field to generate the text that appears on the dropdown menu in the sidebar. When you rename these index pages, you also need to update their `label` in the sidebar file.
47+
48+
### Redirecting Pages
49+
50+
When you move a page, update redirects in the `@docusaurus/plugin-client-redirects` field within the `docusaurus.config.js` file. This file is located in the top level of the repo.
51+
52+
The schema for docs redirects looks like this:
53+
54+
```JS
55+
{
56+
to: '/faq/general-faq',
57+
from: '/faq'
58+
}
59+
{
60+
to: '/v2.6/faq/general-faq',
61+
from: '/v2.6/faq'
62+
},
63+
```
64+
65+
Docusaurus redirects don't accept wildcards, so each path must be exact. This means that you must add individual redirects for each version of a doc.
66+
67+
Docusaurus also can't redirect pages whose filenames contain a period before the extension. You'll need to manually update any docset links to those pages.

0 commit comments

Comments
 (0)