Deploy Docusaurus into Github page
· 2 min read
Deploy Docusaurus into Github page
- Install nodejs (https://nodejs.org/en/download)
- Open terminal and type
node -v
to check node version - Create empty repo on Github
- Create empty folder and run
npx create-docusaurus@latest blog classic
- Run
npm run start
to check - Edit file
docusaurus.config.js
with following contenturl
: https://your-github-name.github.iobaseUrl
:/{repo-name}/
(ex:/test-blog/
)organizationName
: your GitHub user nameprojectName
: repo name created in step 3trailingSlash
: false
- Create
.github/workflows
folders in project - Create
deploy.yml
file inworkflow
with content
deploy.yml
name: Deploy to GitHub Pages
on:
push:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build website
run: npm run build
- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build
deploy:
name: Deploy to GitHub Pages
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- Create
test-deploy.yml
file inworkflow
with content
test-deploy.yml
name: Test deployment
on:
pull_request:
branches:
- main
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Test build website
run: npm run build
- Push to github
- Go to repo setting on github
tip
Prompt to create icon
sticker design, icon, flat color, 2 color only black and white, coder, transparent background