Deploy Docusaurus Sites with ZEIT Now

Docusaurus with ZEIT Now makes it easy to create and deploy open source project documentation.

Docusaurus is a documentation framework that makes it easy to maintain open source documentation websites.

Step 1: Set Up Your Docusaurus Project

Firstly, set up a Docusaurus project by installing the Docusaurus CLI globally from your terminal:

npm i -g docusaurus-init

Installing docusaurus-init globally with npm.

Create and move into a directory for your Docusaurus website:

mkdir my-docs && cd my-docs

Creating and entering into the /my-docs directory.

Run the following command to create a Docusaurus project inside of the /my-docs directory:

docusaurus-init && cd website

Creating a Docusaurus project with the Docusaurus CLI and entering into the /website directory.

You will find that the Docusaurus CLI has created both a /docs and /website directory. Move the /docs directory inside of the /website directory, you can edit its contents later to provide your own documentation.

Add the following two lines of code to the /website/siteConfig.js file:

// See https://docusaurus.io/docs/site-config for all the possible
// site configuration options.
+ const path = require('path');

// List of projects/orgs using your project for the users page.
const users = [
  {
    caption: 'User1',
    // You will need to prepend the image path with your baseUrl
    // if it is not '/', like: '/test-site/img/image.jpg'.
    image: '/img/undraw_open_source.svg',
    infoLink: 'https://www.facebook.com',
    pinned: true,
  },
];

const siteConfig = {
+  customDocsPath: path.basename(__dirname) + '/docs',

Specifying the /docs path in the /website/siteConfig.js file.

Adding these two lines tells Docusaurus to use the path module to define where the /docs folder is located.

Step 2: Deploying Your Docusaurus Website with ZEIT Now

With a Docusaurus website set up, it is ready to deploy live with Now.

From the website directory, use Now CLI to deploy your website with a single command:

now

Deploying your Docusaurus website with Now CLI.

If you want to deploy your Docusaurus project when you push to a Git repository, you can use either Now for GitHub or Now for GitLab to have your project automatically deployed on every push, and the production domain updated on push to master.



Written By
Written by msweeneydevmsweeneydev
on October 9th 2019