Skip to main content

Document Site Deployment

This section will guide how to deploy the document site to various platforms.

Getting Started

This document will guide to deploy the document site to:

  • Netlify (Current): a platform for building, deploying, and hosting modern web projects.
  • Vercel (Recommend): a platform for static sites and Serverless Functions.
  • Render: a platform for deploying and hosting modern apps.
  • GitHub Pages: a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.

For more information, please refer to the official documentation.

note

This document assumes that you have already created an account and logged in with the above platforms.

Deploying to Netlify

To deploy your Docusaurus 2 sites to Netlify, first make sure the following options are properly configured:

docusaurus.config.js
module.exports = {
url: 'https://demo-company-se.netlify.app', // Url to your site with no trailing slash
baseUrl: '/', // Base directory of your site relative to your repo
// ...
};

Then, create your site with Netlify.

netlify-import-project

Choose GitHub as the Git provider and select your repository.

While you set up the site, specify the build commands and directories as follows:

  • build command: pnpm run build
  • publish directory: build

netlify-site-settings

info

If you did not configure these build options, you may still go to "Site settings" -> "Build & deploy" after your site is created.

Then click Deploy site.

Once properly configured with the above options, your site should deploy and automatically redeploy upon merging to your deploy branch, which defaults to main.

Change site name in Site settings -> General -> Site details -> Site name to your own site name (configured in docusaurus.config.js).

netlify-change-sitename

Your site should be deployed and available at the URL specified in the url:

netlify-demo

Deploying to Vercel

You should configure the following options in docusaurus.config.js:

docusaurus.config.js
module.exports = {
url: 'https://demo-company-se.vercel.app', // Url to your site with no trailing slash
baseUrl: '/', // Base directory of your site relative to your repo
// ...
};

Create your site with Vercel by importing your GitHub repository.

vercel-import-project

By default Vercel have already configured the build command and output directory for you:

vercel-site-settings

Then click Deploy.

Change your domains in Domains -> Edit -> Domain to your configured url in docusaurus.config.js:

vercel-change-domain

Click Save and your site should be deployed and available at the URL specified:

vercel-demo

Deploying to Render

You should configure the following options in docusaurus.config.js:

docusaurus.config.js
module.exports = {
url: 'https://demo-company-se.onrender.com', // Url to your site with no trailing slash
baseUrl: '/', // Base directory of your site relative to your repo
// ...
};

Connect your GitHub repository to Render:

render-connect-project

While you set up the site, specify the build commands and directories as follows:

  • name: your site name (configured in docusaurus.config.js, e.g. demo-company-se)
  • build command: pnpm install; pnpm run build
  • publish directory: build

render-site-settings

Click Create Static Site and your site should be deployed:

render-demo

Deploying to GitHub Pages

You should configure the following options in docusaurus.config.js:

NameDescription
organizationNameThe GitHub user or organization that owns the deployment repository.
projectNameThe name of the deployment repository.
deploymentBranchThe name of deployment branch. Defaults to 'gh-pages' for non-organization GitHub Pages repos (projectName not ending in .github.io). Otherwise, this needs to be explicit as a config field or environment variable.
docusaurus.config.js
module.exports = {
url: 'https://duckymomo20012.github.io', // Url to your site with no trailing slash
baseUrl: '/docs', // Base directory of your site relative to your repo
projectName: 'docs',
organizationName: 'duckymomo20012',
trailingSlash: false,
// ...
};
caution

You will have to manually change link in your pages to use baseUrl instead of /, e.g.: <Link to="/docs"> to <Link to=/docs/docs/intro>.

Finally, to deploy your site to GitHub Pages, run:

GIT_USER=<GITHUB_USERNAME> pnpm run deploy
info

For automated deployment, you can use GitHub Actions, following the steps in the official documentation.

And your site should be deployed properly:

gh-pages-demo

Add a custom domain

You can add a custom domain to your site by going to Site settings -> Domain management and clicking Add custom domain:

add_custom_domain

You can enable HTTPS by configuring in HTTPS section.

enable_tls_ssl