How to Deploy to GitHub Pages
This guide shows you how to deploy your documentation to GitHub Pages using DocuMCP's automated workflows. DocuMCP uses a dual-static-site-generator approach for optimal deployment.
Architecture Overview
DocuMCP employs a dual SSG strategy:
- Docusaurus: Primary documentation system for development and rich content
- Jekyll: GitHub Pages deployment for reliable hosting
- Docker: Alternative testing and deployment method
Quick Deployment
For immediate deployment:
# Prompt DocuMCP:
"deploy my documentation to GitHub Pages"
Prerequisites
- Repository with documentation content
- GitHub account with repository access
- GitHub Pages enabled in repository settings
- Node.js 20.0.0+ for Docusaurus development
Deployment Methods
Method 1: Automated with DocuMCP (Recommended)
Use DocuMCP's intelligent deployment:
# Complete workflow:
"analyze my repository, recommend SSG, and deploy to GitHub Pages"
This will:
- Analyze your project structure
- Set up Docusaurus for development
- Configure Jekyll for GitHub Pages deployment
- Create GitHub Actions workflow
- Deploy to Pages
Method 2: Current DocuMCP Setup
DocuMCP currently uses the following deployment workflow:
GitHub Actions Workflow
name: Deploy Jekyll to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
bundler-cache: true
- name: Build with Jekyll
run: bundle exec jekyll build
env:
JEKYLL_ENV: production
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: "./_site"
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Development vs Production
- Development: Use Docusaurus (
cd docs && npm start) - Production: Jekyll builds and deploys to GitHub Pages
- Testing: Use Docker (
docker-compose -f docker-compose.docs.yml up)
Method 3: Manual Configuration
If you prefer manual setup:
Step 1: Choose Your SSG
# Get recommendation first:
"recommend static site generator for my project"
Step 2: Generate Config
# For example, with Hugo:
"generate Hugo configuration for GitHub Pages deployment"
Step 3: Deploy
"set up GitHub Pages deployment workflow for Hugo"
GitHub Actions Workflow
DocuMCP generates optimized workflows for each SSG:
Docusaurus Workflow
name: Deploy Docusaurus
on:
push:
branches: [main]
paths: ["docs/**", "docusaurus.config.js"]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: "./build"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Hugo Workflow
name: Deploy Hugo
on:
push:
branches: [main]
paths: ["content/**", "config.yml", "themes/**"]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "latest"
extended: true
- name: Build
run: hugo --minify
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: "./public"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
MkDocs Workflow
name: Deploy MkDocs
on:
push:
branches: [main]
paths: ["docs/**", "mkdocs.yml"]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install mkdocs mkdocs-material
- name: Build
run: mkdocs build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: "./site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Repository Configuration
GitHub Pages Settings
- Navigate to repository Settings
- Go to Pages section
- Set Source to "GitHub Actions"
- Save configuration
Branch Protection
Protect your main branch:
# .github/branch-protection.yml
protection_rules:
main:
required_status_checks:
strict: true
contexts:
- "Deploy Documentation"
enforce_admins: false
required_pull_request_reviews:
required_approving_review_count: 1
Custom Domain Setup
Add Custom Domain
- Create
CNAMEfile in your docs directory:
docs.yourdomain.com
- Configure DNS records:
CNAME docs yourusername.github.io
- Update DocuMCP deployment:
"deploy to GitHub Pages with custom domain docs.yourdomain.com"