Skip to main content

Docusaurus Migration via GitHub Repo

First lets create the root directory on your new host.

sudo mkdir /var/websites && sudo mkdir /var/websites/<example> && cd /var/websites/<example>
info

Change <example> to whatever you want to name the folder. Mine will be named BankaiTechDocs

Installing Dependencies

sudo apt install git && sudo apt install npm

Creating local SSH key

Go to your terminal and run this command

ssh-keygen -t ed25519 -C "[email protected]"

Press ENTER and follow the prompts

Generate Keys

Recommended

You do not need to enter a passphrase but it is recommended for security

warning

If you do use a Passphrase, please keep it safe as you will need it every time you run Git pull or Git push

Run the following command and copy the contents of the result

cat <location of new ssh key>
info

I ran cat /root/.ssh/id_ed25519.pub

Adding SSH key to GitHub

In the upper-right corner of any page, click your profile photo, then click Settings.

GitHub Settings

In the "Access" section of the sidebar, click SSH and GPG keys.

SSH and GPG keys

Click New SSH key

New SSH key

You should now see this screen

Paste key

note

I used my repo name BankaiTechDocs for the Key name
Key type is Authentication key

Paste the new SSH key in the box and click Add SSH key

Creating a local .git repo

Go to the root directory of your website

note

This directory will contain your docusaurus.config.js or docusaurus.config.ts file

In your terminal, run the following commands

git init
git config --global user.name "<USER_NAME>"
git config --global user.email "<USER_EMAIL>"

Connecting to the remote Repo

We are going to need the SSH url for your repo, we can find that here

Repo URL

Run this command to add your remote repo

git remote add origin <SSh Repo URL>
Example

[email protected]:TrueBankai416/BankaiTechDocs.git

Security

Installing talisman

Go to the root directory of your website and run the following

sudo apt install curl && curl --silent  https://raw.githubusercontent.com/thoughtworks/talisman/main/global_install_scripts/install.bash > /tmp/install_talisman.bash && /bin/bash /tmp/install_talisman.bash

Installing Docusaurus

sudo npm install docusaurus && sudo npm audit fix

Installing module for Environment Variables

sudo npm install dotenv --save

Pulling Docs from GitHub

Now run the following commands

git pull origin main

You should now be able to make changes on GitHub and then run git pull origin main to download the changes locally, or you can make changes locally and run git push origin main to send the changes to GitHub

Now if you have any environment variables or secrets inside an .env file or other file then you will need to move them over to the new host or npm run build will fail.

note

When you run git pull origin main you will have to run npm run build afterwards to apply the changes



Hi, how can I help you?