Skip to content

Commit ba1a20d

Browse files
authored
Update and improve the docs Markdown writing instructions (#2694)
Signed-off-by: Julius Volz <[email protected]>
1 parent c90124f commit ba1a20d

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

markdown-guide.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,57 @@
1-
# Guide around Markdown features, formatting, and frontmatter fields
1+
# Markdown documentation formatting guide
22

33
This document gives an overview of the Markdown features and formatting options available for the docs in this repository. It also provides information about the frontmatter fields that can be used to customize the behavior and appearance of the documentation pages.
44

5+
These documentation pages live in:
6+
7+
* General documentation: https://github.com/prometheus/docs/tree/main/docs
8+
* Prometheus server documentation: https://github.com/prometheus/prometheus/tree/main/docs
9+
* Alertmanager documentation: https://github.com/prometheus/alertmanager/tree/main/docs
10+
511
## Markdown features
612

7-
Generally, we use [GitHub Flavored Markdown](https://github.github.com/gfm/) for formatting and add some custom filters on top:
13+
Generally, we use [GitHub Flavored Markdown](https://github.github.com/gfm/) for formatting with some custom filters on top:
814

9-
* Paragraphs that start with `TIP:`, `NOTE:`, `CAUTION:`, or `TODO:` are automatically converted to alert boxes with an appropriate icon and color.
10-
* Code blocks are automatically highlighted using [Shiki](https://shiki.matsu.io/).
11-
* On configuration pages like https://prometheus.io/docs/prometheus/latest/configuration/configuration/, any inline `<code>` element with a text pattern of `<placeholder>` (e.g. `<string>` or `<scrape_config>`) will be identified as a type definition, and references to those placeholders in code boxes will be linked to them.
12-
* Links to images and other pages are normalized in various ways to point to the right locations, show external link icons, etc.
15+
* **Alert boxes:** Paragraphs that start with `TIP:`, `NOTE:`, `CAUTION:`, or `TODO:` are automatically converted to alert boxes with an appropriate icon and color.
16+
* **Syntax highlighting:** Code blocks are automatically highlighted using [Shiki](https://shiki.matsu.io/).
17+
* **Config placeholder definition linking:** On configuration pages like https://prometheus.io/docs/prometheus/latest/configuration/configuration/, any inline `<code>` element with a text pattern of `<placeholder>` (e.g. `<string>` or `<scrape_config>`) will be identified as a type definition, and references to those placeholders in code boxes will be linked to them.
18+
* **Link normalization:** Links to images and other pages are normalized in various ways to point to the right locations, show external link icons, etc.
1319

14-
## Heading levels
20+
## Frontmatter fields
1521

16-
For blog posts and documentation pages, please use headings in the following ways:
22+
The following frontmatter fields are available:
1723

1824
### For documentation pages
1925

20-
* Start the Markdown content with a single top-level heading (`# Heading`, `<h1>`) that reflects the page title (should usually be the same as the `title` frontmatter field).
21-
* Use second-level headings (`## Heading`, `<h2>`) for the main sections of the page and use lower-level headings for subsections as appropriate.
26+
| Field | Description |
27+
|-------|-------------|
28+
| `title` | The title of the page. This is displayed as the main heading on the page and as the HTML page title. |
29+
| `nav_title` | (OPTIONAL) An alternate (usually shorter) title to show in the navigation menu and in the previous/next pagination buttons. If not set, the `title` field is used. |
30+
| `sort_rank` | The sort order of the page relative to its sibling pages in the same directory. Pages with a lower sort rank will appear first in the navigation menu. Should start at 1 and be incremented by 1 for each page in the same directory. |
31+
| `nav_icon` | (OPTIONAL) The [Tabler](https://tabler.io/icons) icon to be displayed in the navigation menu for this section. This is only used for the top-level section `index.md` Markdown files and doesn't have any effect when used in actual documentation pages. Any new icons need to be added to the `iconMap` in [`src/app/docs/layout.tsx`](src/app/docs/layout.tsx). |
32+
| `hide_in_nav` | (OPTIONAL) If set to `true`, the page will not be included in the navigation menu but still be accessible via its URL. |
2233

2334
### For blog posts
2435

25-
* **DO NOT use any top-level headings (`# Heading`, `<h1>`) in the Markdown content itself.** The final rendered page will include an automatic H1 heading based on the `title` frontmatter field.
36+
| Field | Description |
37+
|-------|-------------|
38+
| `title` | The title of the blog post. This is displayed as the main heading on the page and as the HTML page title. |
39+
| `author_name` | The name of the author of the blog post. |
40+
| `created_at` | The date of the blog post in `YYYY-mm-dd` format. |
41+
42+
## Proper usage of heading levels
43+
44+
For both blog posts and documentation pages, please use headings in the following ways:
45+
46+
* **DO NOT use any top-level headings (`# Heading`, `<h1>`) in the Markdown content itself.** The final rendered page will already include an automatic H1 heading based on the `title` frontmatter field.
2647
* Use second-level headings (`## Heading`, `<h2>`) for the main sections of the blog post and use lower-level headings for subsections as appropriate.
2748

28-
### Links between pages
49+
## Links between pages
2950

3051
When linking *between* documentation pages, use the following rules:
3152

3253
* When linking between docs within the same repository:
3354
* Use either a full repo-rooted path (`/docs/concepts/data_model.md`) or a relative file path (`../guides/utf8.md`) in such a way that the link also works on GitHub.
3455
* Note: Keep the `.md` extension in the link.
3556
* When linking between docs that live in different source repos:
36-
* Use absolute site URL paths that start with `/docs/...`, omit the `.md` extension, but end with a slash, e.g. `/docs/concepts/data_model/`.
37-
38-
## Frontmatter fields
39-
40-
The following frontmatter fields are available:
41-
42-
### For local and remote documentation pages
43-
44-
* `title`: The title of the page. This is displayed as the main heading on the page and as the HTML page title.
45-
* `sort_rank`: The sort order of the page relative to its sibling pages in the same directory. Pages with a lower sort rank will appear first in the navigation menu. Should start at 1 and be incremented by 1 for each page.
46-
* `nav_title` (OPTIONAL): The title to show in the navigation menu. If not set, the `title` field is used. This can be useful for showing a shorter title in the navigation menu, if necessary.
47-
* `hide_in_nav` (OPTIONAL): If set to `true`, the page will not be included in the navigation menu but still be accessible via its URL.
48-
* `nav_icon` (OPTIONAL): The [Tabler](https://tabler.io/icons) icon to be displayed in the navigation menu for this section. This is only used for the top-level section `index.md` Markdown files. Any new icons need to be added to the `iconMap` in [`src/app/docs/layout.tsx`](src/app/docs/layout.tsx).
49-
50-
### For blog posts
51-
52-
* `title`: The title of the blog post. This is displayed as the main heading on the page and as the HTML page title.
53-
* `author_name`: The name of the author of the blog post.
54-
* `created_at`: The date of the blog post in `YYYY-mm-dd` format.
57+
* Use absolute Prometheus website URL paths that start with `/docs/...`, omit the `.md` extension, and end the link with a slash, e.g. `/docs/concepts/data_model/` (links without a trailing slash will still work, but will incur an additional redirect).

0 commit comments

Comments
 (0)