Docusaurus was created to hopefully make it super simple for you to create a site and documentation for your open source project.

After installation and preparation, much of the work to create a basic site for your docs is already complete.

Site Structure

Your site structure looks like the following:

  1. root-directory
  2. ├── docs
  3. └── website
  4. ├── blog
  5. ├── core
  6. └── Footer.js
  7. ├── package.json
  8. ├── pages
  9. ├── sidebars.json
  10. ├── siteConfig.js
  11. └── static

This assumes that you removed the example .md files that were installed with the initialization script.

All of your documentation files should be placed inside the docs directory as markdown .md files. Any blog posts should be inside the blog directory.

The blog posts must be formatted as YYYY-MM-DD-your-file-name.md

Create Your Basic Site

To create a fully functional site, you only need to do a few steps:

  1. Add your documentation to the /docs directory as .md files, ensuring you have the proper header in each file. One example header would be the following, where id is the link name (e.g., docs/intro.html) and the title is the webpage’s title.

    1. ---
    2. id: intro
    3. title: Getting Started
    4. ---
    5. My new content here..
  1. Add zero or more docs to the sidebars.json file so that your documentation is rendered in a sidebar if you choose them to be.

If you do not add your documentation to the sidebars.json file, the docs will be rendered, but they can only be linked to from other documentation and visited with the known URL.

  1. Modify the website/siteConfig.js file to configure your site, following the comments included in the docs and the website/siteConfig.js to guide you.
  2. Create any custom pages and/or customize the website/core/Footer.js file that provides the footer for your site.
  3. Place assets, such as images, in the website/static/ directory.
  4. Run the site to see the results of your changes.

    cd website yarn run start # or npm run start

    Navigate to http://localhost:3000

Special Customization

Docs Landing Page

If you prefer to have your landing page be straight to your documentation, you can do this through a redirect.

  1. Remove the index.js file from the website/pages directory, if it exists.
  2. Add a custom static index.html page in the website/static directory with the following contents:

    1. <!DOCTYPE html>
    2. <html lang="en-US">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta
    6. http-equiv="refresh"
    7. content="0; url=docs/id-of-doc-to-land-on.html"
    8. />
    9. <script type="text/javascript">
    10. window.location.href = 'docs/id-of-doc-to-land-on.html';
    11. </script>
    12. <title>Your Site Title Here</title>
    13. </head>
    14. <body>
    15. If you are not redirected automatically, follow this
    16. <a href="docs/id-of-doc-to-land-on.html">link</a>.
    17. </body>
    18. </html>

You will get the id of the document to land on the .md metadata of that doc page.

Blog Only

You can also use Docusaurus to host your blog only.