End-to-end guide to deploy this Next.js static site to GitHub Pages.
- The only runnable Next.js app in this repo lives in
demo/. - The repo root has no
package.json, so all dev and build commands must be run fromdemo/. components/andpages/are template sources only - they are not routed pages.
- Node.js 18+ installed locally
- GitHub account
- Git installed locally
- Go to github.com/new
- Repository name:
bulma-root - Description: "Bulma marketing website"
- Visibility: Public (required for GitHub Pages on free tier)
- Do NOT initialize with README, .gitignore, or license
- Click Create repository
# Install gh CLI if needed: brew install gh
gh auth login
gh repo create bulma-root --public --description "Bulma marketing website"Edit demo/next.config.ts:
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
output: 'export',
basePath: '', // Leave empty for custom domain, or use '/repo-name' for github.io
images: {
unoptimized: true, // Required for static export
},
trailingSlash: true, // Recommended for GitHub Pages
}
export default nextConfigIn demo/package.json, ensure these scripts exist:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
}
}Create .github/workflows/deploy.yml in the repository root:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.18.3"
cache: "npm"
cache-dependency-path: demo/package-lock.json
- name: Install dependencies
working-directory: demo
run: npm ci
- name: Build
working-directory: demo
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: demo/out
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4Create demo/public/CNAME:
bulma.com.au
Add these records in your DNS provider:
Option A: Apex domain (bulma.com.au)
Type: A
Name: @
Value: 185.199.108.153
Type: A
Name: @
Value: 185.199.109.153
Type: A
Name: @
Value: 185.199.110.153
Type: A
Name: @
Value: 185.199.111.153
Option B: www subdomain (www.bulma.com.au)
Type: CNAME
Name: www
Value: <username>.github.io
- Go to repository Settings > Pages
- Under Source, select GitHub Actions (build from workflow, not from branch/root)
- Under Custom domain, enter
bulma.com.au - Check Enforce HTTPS (after DNS propagates)
cd bulma-root
# Initialize git repository
git init
git branch -M main
# Create .gitignore
cat > .gitignore << 'EOF'
# Dependencies
node_modules/
demo/node_modules/
# Next.js
demo/.next/
demo/out/
# IDE
.idea/
# OS
.DS_Store
Thumbs.db
# Environment
.env
.env.local
.env.*.local
EOF
# Stage all files
git add .
# Initial commit
git commit -m "Initial commit: Bulma marketing site template"
# Connect to GitHub (replace <username> with your GitHub username)
git remote add origin git@github.com:<username>/bulma-root.git
# Push to GitHub (default branch must be main)
git push -u origin mainAfter pushing:
- Go to Actions tab in GitHub to monitor the workflow
- Once complete, visit
bulma.com.au(after DNS propagation, 5min - 48hrs) - Check Settings > Pages for deployment status
cd demo
npm install
npm run dev
# Visit http://localhost:3000cd demo
npm run build
# Output in demo/out/Ensure images.unoptimized: true is set in next.config.ts
Ensure trailingSlash: true is set in next.config.ts
- Wait for DNS propagation (up to 48 hours)
- Verify CNAME file exists in
demo/public/CNAME - Check A records point to GitHub's IPs
- Verify
basePathis correct (empty for custom domain) - Check browser console for 404 errors
bulma-root/
├── .github/
│ └── workflows/
│ └── deploy.yml
├── .vscode/
│ └── launch.json # VS Code debug configurations
├── demo/
│ ├── public/
│ │ ├── CNAME
│ │ └── img/
│ ├── src/
│ │ ├── app/
│ │ └── components/
│ ├── next.config.ts
│ └── package.json
├── components/ # Template components (reference)
├── pages/ # Template page variants (reference)
├── .gitignore
├── github-pages-setup.md
├── files-to-change.md
└── README.md
- GitHub Pages is pointing at the repo root instead of workflow output.
- Fix by forcing workflow builds:
gh api repos/Culpable/bulma-root/pages -X PUT -f build_type=workflow && gh workflow run deploy.yml