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:
Kayce Basques 2022-03-16 16:54:18 -07:00 committed by GitHub
parent da9f38b748
commit 284649c7c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,17 +37,31 @@ id: part1
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
---
id: part1
slug: part1.html
slug: /bonjour
---
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
It is possible to use: