mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 15:07:17 +02:00
docs: clarify the usage of slug (#6926)
* Clarify the usage of slug As a new user it was unclear whether setting `slug` would change the URL relative to the root directory or relative to the docs directory. The example I added should make that clear without needing to test out the functionality in a Docusaurus instance (which is what I had to do). * editorial changes Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
da9f38b748
commit
284649c7c8
1 changed files with 17 additions and 3 deletions
|
@ -37,17 +37,31 @@ id: part1
|
||||||
Lorem ipsum
|
Lorem ipsum
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want more control over the last part of the document URL, it is possible to add a `slug` (defaults to the `id`).
|
### Customizing doc URLs {#customizing-doc-urls}
|
||||||
|
|
||||||
|
By default, a document's URL location is its file path relative to the `docs` folder. Use the `slug` front matter to change a document's URL.
|
||||||
|
|
||||||
|
For example, suppose your site structure looks like this:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
website # Root directory of your site
|
||||||
|
└── docs
|
||||||
|
└── guide
|
||||||
|
└── hello.md
|
||||||
|
```
|
||||||
|
|
||||||
|
By default `hello.md` will be available at `/docs/guide/hello`. You can change its URL location to `/docs/bonjour`:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
---
|
---
|
||||||
id: part1
|
slug: /bonjour
|
||||||
slug: part1.html
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Lorem ipsum
|
Lorem ipsum
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`slug` will be appended to the doc plugin's `routeBasePath`, which is `/docs` by default. See [Docs-only mode](#docs-only-mode) for how to remove the `/docs` part from the URL.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
||||||
It is possible to use:
|
It is possible to use:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue