DEV Community

Simon Boisset
Simon Boisset

Posted on

Create multiple docs with Docusaurus

Docusaurus is an open source framework developed by Facebook and based on react. It allows you to create clean, versionable and multilingual documentation with a very small configuration.

Create your project

Initialize your project with the following command:

npx @docusaurus/init@latest init my-website classic --typescript
Enter fullscreen mode Exit fullscreen mode

You can then start your development mode.

cd my-websiteyarn start
Enter fullscreen mode Exit fullscreen mode

Project structure

In the same philosophy as Jekyll you will be able to generate a static site based on markdown files but you can also create pages directly in jsx.

Docs file The docs file contains all the chapters of your documentation. We will see how to configure it to have two distinct documentations.

Create a second documentation

Docusaurus Config

We want to create two documentations, one Guide and the other Api. We will add an item in the navbar configuration.

navbar: {
 {
  type: 'doc',
  docId: 'guide/intro',
  position: 'left',
  label: 'Docs',
 },
 {
  type: 'doc',
  docId: 'api/intro',
  position: 'left',
  label: 'Api',
 },
}
Enter fullscreen mode Exit fullscreen mode

Sidebars

We modify the Sidebars to include the two documentation and set their dirName to subfolders that we will create in the docs folder.

module.exports = {
    docSidebar: [{ type: 'autogenerated', dirName: 'guide' }],
    apiSidebar: [{ type: 'autogenerated', dirName: 'api' }],
};
Enter fullscreen mode Exit fullscreen mode

Writing documentation

Now you have to create two folders docs/guide and docs/api in which you can create your two documentations.

Top comments (2)

Collapse
 
cynthiahoang profile image
CynthiaHoang

Is there a way to have two docs in Docusaurus 2? Voodoo break up spell

Collapse
 
sebarach profile image
sebarach

Nice bro