mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 02:08:36 +02:00
57 lines
1.2 KiB
Text
57 lines
1.2 KiB
Text
---
|
|
id: headings
|
|
title: Headings
|
|
description: Using Markdown headings
|
|
slug: /markdown-features/headings
|
|
---
|
|
|
|
## Markdown headings {#markdown-headings}
|
|
|
|
You can use regular Markdown headings.
|
|
|
|
```
|
|
## Level 2 title
|
|
|
|
### Level 3 title
|
|
|
|
#### Level 4 title
|
|
```
|
|
|
|
Markdown headings appear as a table of contents entry.
|
|
|
|
## Heading ids {#heading-ids}
|
|
|
|
Each heading has an id that can be automatically generated or explicitly specified.
|
|
|
|
Heading ids allow you to link to a specific document heading in Markdown or JSX:
|
|
|
|
```md
|
|
[link](#heading-id)
|
|
```
|
|
|
|
```jsx
|
|
<Link to="#heading-id">link</Link>
|
|
```
|
|
|
|
### Generated ids {#generated-ids}
|
|
|
|
By default, Docusaurus will generate heading ids for you, based on the heading text. For example, `### Hello World` will have id `hello-world`.
|
|
|
|
Generated ids have **some limits**:
|
|
|
|
- The id might not look good
|
|
- You might want to **change or translate** the text without updating the existing id
|
|
|
|
### Explicit ids {#explicit-ids}
|
|
|
|
A special Markdown syntax lets you set an **explicit heading id**:
|
|
|
|
```md
|
|
### Hello World {#my-explicit-id}
|
|
```
|
|
|
|
:::tip
|
|
|
|
Use the **[write-heading-ids](../../cli.md#docusaurus-write-heading-ids-sitedir)** CLI command to add explicit ids to all your Markdown documents.
|
|
|
|
:::
|