Use Docs
Docs are located under /docs directory by default.
Create a docβ
Create a Markdown file, greeting.md, and place it under the /docs directory.
website # root directory of your site
βββ docs
β βββ greeting.md
βββ ...
Front Matterβ
---
title: Name Of Doc
id: your-doc
slug: /your-doc
description: Create a Markdown Document
tags:
- Demo
- Getting started
sidebar_position: 10
---
title for doc Titleβ
This field is optional, by default
h1in document body will be used for the title.Use
titlein Front Matter will change the sitebar and webpage title.If there is no
h1in the document body,titlewill be used in the page.
id for doc Identifierβ
This field is optional, by default the filename of the doc is used as
idfor the document.idis also used in the url to the doc by default.idis unique when linking resources, such as usedocIdto link to the doc in navbar.Sometimes multiple docs can have the same filename under different directory, to use
docIdto link these 2 docs, differentidshould be set.
website # root directory of your site
βββ docs
β βββ guide-for-something
β β βββ `step-1.md`
β βββ guide-for-something-else
β βββ `step-1.md`
βββ ...
slug for doc Urlβ
This field is optional, by default docusaurus will use
directory/filenameordirectory/docIdas the url for the doc.You can override the default url by using
slugfield. Even create non-exsiting directorys:
// doc location
βββ docs
β βββ demo
β β βββ docname
βββ ...
// Front Matter slug Override
slug: /this/is/a/cool/name
When Docs routeBasePath is /docs, that doc url will be your.domain/docs/this/is/a/cool/name other than the default your.domain/docs/demo/docname.
description fieldβ
This field is optional.
Can be useful for SEO.
tags fieldβ
- This field is optional.
note
Tags in docs and blog are not shared, they are in separated namespaces.
sidebar_position fieldβ
This field is optional, but it's recommended to set mannually to keep the docs in order.
sidebar_positionset the orders of docs in the same directory level.This also orders the
Previous / Nextpage feature.
Docs routeBasePathβ
This template uses
/as docs routeBasePath by default.As this doc
/docs/quick-setup/use-docs.mdis using url:your.domain/quick-setup/use-docs.
Change Docs routeBasePathβ
Use
/docsas Docs routeBasePath will move docs underyour.domain/docs/.Then this doc's url will be changed to
your.domain/docs/quick-setup/use-docs.
const config = {
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
- routeBasePath: '/',
+ routeBasePath: '/docs',
},
}),
],
],
};
note
This template uses /docs/start.md as homepage.
After changing routeBasePath from '/' to other location, the homepage will unable to access, You will need to create a homepage after changing the docs routeBasePath.