Deploying a documentation website with Docusaurus on Scaleway
Docusaurus is an open-source documentation framework. It allows you to build, deploy, and maintain documentation websites. It comes with features such as blogs, internationalization, search, and versioning.
It builds a single-page application with fast client-side navigation, leveraging the full power of React to make your site interactive. The tool is a static-site generator and provides out-of-the-box documentation features - but can be used to create any kind of static website (personal website, product, blog, marketing landing pages, etc.).
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An Object Storage bucket with the bucket website feature enabled
- A GitHub account and an empty repository for your documentation project
- A local development environment with Node.js (version 16.14 or above) and
git
installed
Generating a new site
Docusaurus is available for most operating systems. In this tutorial, we describe the installation on an Ubuntu Linux system. For other operating systems, refer to the official documentation.
- Open a terminal on your computer.
- Type the following command in the terminal to generate a new Docusaurus site:
You will be prompted to install the latest
npx create-docusaurus@latest
create-docusaurus
package (here 3.4.0). Typey
to proceed.Once the installation is complete, you will be prompted to provide some information about your new documentation website:Need to install the following packages: create-docusaurus@3.4.0 Ok to proceed? (y) y
- A name for your new site (for example:
docusaurus-on-scaleway
) - A template for your website (for example:
classic (recommended)
) - Confirm that you want to use the TypeScript version of the template by typing
y
.
Docusaurus will create the new site and all related files.✔ What should we name this site? … docusaurus-on-scaleway ✔ Select a template below... › classic (recommended) ✔ This template is available in TypeScript. Do you want to use the TS variant? … yes
- A name for your new site (for example:
- Enter the directory of your new site:
You can see that Docusaurus created several files and directories:
cd docusaurus-on-scaleway
ls README.md docusaurus.config.js sidebars.js babel.config.js node_modules src blog package-lock.json static docs package.json tsconfig.json
- Deploy a preview of your site using the development web server by running the following command:
Your browser opens a new tab automatically, pointing to
npm start
http://localhost:3000
, and displaying the Docusaurus site. - Run the following command to initialize a new git repository inside the Docusaurus website folder on your local computer:
git init
- Configure a remote upstream of your repository, pointing to your GitHub repository:
git remote add origin git@github.com:<YOUR_GITHUB_USER>/<YOUR_GITHUB_REPOSITORY_NAME>.git
- Add the Docusaurus files to your repository, commit, and push the changes:
git add . git commit -m "Initial commit" git push -u origin main
Deploying to Scaleway Object Storage
- Open a web browser and go to your project's repository on GitHub.com.
- Click the Settings tab to display the settings of your repository.
- Click Secrets > Actions in the side menu. A list of the Actions' secrets displays. GitHub Secrets are encrypted data of sensitive information. They are used here to store the Scaleway secret key and access key.
- Click New repository secret to create a new secret. Name it
SCW_ACCESS_KEY_ID
and enter your access key as secret value. - Click Add secret to save your configuration.
- Repeat the step above with a secret named
SCW_SECRET_ACCESS_KEY
and your secret key as secret value. - Repeat the step above again and set a secret named
SCW_S3_BUCKET
and your bucket name as secret value. - Click the Actions tab. A list of suggested GitHub Actions for your project displays.
- Click Skip this and set up a workflow yourself.
- Copy the following code in the text editor, keep the default file name
main.yml
and click Start commit:name: Deploy Docusaurus to Object Storage on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: bene2k1/s3-docusaurus-sync-action@main env: SCW_BUCKET_REGION: "fr-par" # Set this to the region corresponding to the geographical location of your bucket SCW_S3_BUCKET: ${{ secrets.SCW_S3_BUCKET }} SCW_ACCESS_KEY_ID: ${{ secrets.SCW_ACCESS_KEY_ID }} SCW_SECRET_ACCESS_KEY: ${{ secrets.SCW_SECRET_ACCESS_KEY }}
- Enter a commit message, select Commit directly to the
main
branch and click Commit new file.
The runner runs automatically for the first time and builds and deploys your documentation website to the Object Storage bucket.
Adding more pages
You can add several types of content to your Docusaurus site:
Refer to the official documentation for more information about the different types of content.
Once you have created your content, add it to your working tree, then commit and push it to your GitHub repository:
git add .
git commit -m "More content commit"
git push -u origin main
The GitHub runner will run Docusaurus and build your website. It will then deploy it on your Scaleway Object Storage.
Conclusion
Docusaurus is now set up to rebuild your site every time you push new content to the main
branch of your GitHub repository. Docusaurus then deploys it automatically on your Object Storage website.
All changes go live on your website as soon as the GitHub runner has completed its tasks and the build of your website is completed successfully.
For more information about Docusaurus, refer to the official documentation. An alternative solution to Docusaurus is Hugo, which provides similar features.
Visit our Help Center and find the answers to your most frequent questions.
Visit Help Center