Skip to main content

Deploy a Docusaurus site to GitHub Pages

In this tutorial, you'll learn how to deploy a Docusaurus documentation site to GitHub Pages. This tutorial is intended for users who are new to Docusaurus and GitHub Pages. It assumes you have knowledge of:

  • Basic command-line usage
  • A GitHub account
  • A local installation of Node.js and Yarn

By the end of this tutorial, you'll have seen how to:

  • Clone a Docusaurus project from GitHub
  • Configure a website for deployment to GitHub Pages
  • Access the deployed site in a web browser

Before you start

Before you start this tutorial, ensure that you have:

  • A GitHub account
  • A local development environment with Node.js (version 20 or later) installed
  • Yarn installed
  • Access to a terminal

Deploy the site

To deploy a Docusaurus site to GitHub Pages, follow these steps.

  1. Clone the Docusaurus project from GitHub.

    Open a terminal and clone the repository to your local machine.

    git clone https://YOUR_GITHUB_USERNAME/YOUR_GITHUB_USERNAME/YOUR_REPOSITORY_NAME.git
  1. Navigate to the project directory.

    cd YOUR_REPOSITORY_NAME
  2. Update the Docusaurus configuration for GitHub Pages.

Open the docusaurus.config.ts file and update the following properties to match your GitHub account and repository:

  • url
  • baseUrl
  • organizationName
  • projectName
  1. Install the project dependencies.
yarn
  1. Deploy the site to GitHub Pages.
yarn deploy
  1. Open the deployed site in a web browser.

After the deployment completes, access the site at:

https://YOUR_GITHUB_USERNAME.github.io/YOUR_REPOSITORY_NAME/

Summary

In this tutorial, you learned how to:

  • Clone a Docusaurus project from GitHub
  • Configure a Docusaurus site for GitHub Pages
  • Deploy the site using a single command
  • Access the deployed documentation site

Read More

To learn more about Docusaurus, explore the following topics:

  • Creating and organizing documentation content
  • Customizing themes and navigation
  • Managing documentation versions