π Deploy Your Docusaurus Portfolio to GitHub Pages
This tutorial walks you through deploying your personal portfolio built with Docusaurus to GitHub Pages using GitHub Actions.
If you like this portfolio design, feel free to use or fork it from my GitHub repository.
π οΈ Prerequisitesβ
- A GitHub account
- A Docusaurus portfolio project (e.g.,
my-portfolio) - Basic terminal/git knowledge
π Step 1: Push Your Code to GitHubβ
Create a new public or private GitHub repo and push your local portfolio:
git init
git remote add origin https://github.com/USERNAME/REPO_NAME.git
git add .
git commit -m "Initial commit"
git push -u origin main
βοΈ Step 2: Update docusaurus.config.jsβ
url: 'https://USERNAME.github.io',
baseUrl: '/REPO_NAME/', // '/' if it's a personal site
projectName: 'REPO_NAME',
organizationName: 'USERNAME',
For a personal site, use:
baseUrl: '/',
projectName: 'USERNAME.github.io',
π Step 3: Add GitHub Action for Deploymentβ
Install the deploy script:
npm install --save docusaurus
Then add the following to .github/workflows/deploy.yml:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
π Step 4: Enable GitHub Pagesβ
- Go to Repo > Settings > Pages
- Build and deployment
- Source β
Deploy from a branch - Branch β
gh-pages/(root)
- Source β
- Save β
β Done!β
Your site should be available at:
https://USERNAME.github.io
π‘ Troubleshooting Tips
- Use the GitHub Actions tab to debug failed deployments
- For private repos, Pages is supported if youβre on GitHub Pro or Team plans
Now your portfolio is live! π§βπ»