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.
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:
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.
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
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
).
Your site should be deployed and available at the URL specified in the url
:
Deploying to Vercel
You should configure the following options in 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.
By default Vercel have already configured the build command and output directory for you:
Then click Deploy
.
Change your domains in Domains
-> Edit
-> Domain
to your configured url
in docusaurus.config.js
:
Click Save
and your site should be deployed and available at the URL
specified:
Deploying to Render
You should configure the following options in 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:
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
Click Create Static Site
and your site should be deployed:
Deploying to GitHub Pages
You should configure the following options in docusaurus.config.js
:
Name | Description |
---|---|
organizationName | The GitHub user or organization that owns the deployment repository. |
projectName | The name of the deployment repository. |
deploymentBranch | The 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. |
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,
// ...
};
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
For automated deployment, you can use GitHub Actions, following the steps in the official documentation.
And your site should be deployed properly:
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
:
You can enable HTTPS by configuring in HTTPS section.