Deployment
Deploy your Personal Landing page to GitHub Pages with automated workflows. Every push to your main branch will automatically build and deploy your site.
GitHub Pages Deployment
Personal Landing is designed for GitHub Pages, with an automated workflow that builds and deploys your site whenever you push changes.
Initial Setup
1. Push to GitHub
If you haven't already, create a GitHub repository and push your code:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourusername/your-repo-name.git
git push -u origin main
2. Add the Deployment Workflow
Create .github/workflows/deploy.yml in your repository:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_call: # Allow other workflows to trigger this
permissions:
contents: write
concurrency:
group: 'pages'
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
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 site
run: npm run build
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
publish_branch: gh-pages
3. Enable GitHub Pages
- Go to your repository on GitHub
- Navigate to Settings → Pages
- Under Source, select Deploy from a branch
- Select the gh-pages branch and / (root) folder
- Click Save
4. Configure Base Path (if needed)
If you're deploying to username.github.io/repo-name (not a custom domain), update svelte.config.js:
import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: null,
precompress: false,
strict: true,
}),
paths: {
base: process.env.NODE_ENV === 'production' ? '/your-repo-name' : '',
},
},
};
Important: Replace your-repo-name with your actual repository name.
If using a custom domain, you can omit the paths.base configuration.
How It Works
- You push changes to the
mainbranch - GitHub Actions automatically triggers the workflow
- The workflow:
- Checks out your code
- Installs dependencies
- Builds your site (
npm run build) - Deploys the
build/folder to thegh-pagesbranch
- GitHub Pages serves your site from the
gh-pagesbranch
Your Site URL
After deployment, your site will be available at:
- Repository deployment:
https://yourusername.github.io/repo-name - Custom domain:
https://yourcustomdomain.com(see Custom Domain section)
Deployment Status
Check deployment status in your repository:
- Go to the Actions tab
- View the latest workflow run
- Green checkmark = successful deployment
- Red X = deployment failed (click to view logs)
Custom Domain
Use your own domain instead of github.io.
Setup
- Add a
CNAMEfile to thestatic/folder containing your domain:
yourdomain.com
Or for a subdomain:
www.yourdomain.com
- Configure your DNS provider:
For apex domain (example.com):
A @ 185.199.108.153
A @ 185.199.109.153
A @ 185.199.110.153
A @ 185.199.111.153
For subdomain (www.example.com):
CNAME www yourusername.github.io
-
In GitHub repository settings → Pages:
- Add your custom domain
- Enable Enforce HTTPS (recommended)
-
Update
config.json:
{
"domain": "https://yourdomain.com"
}
- Update
svelte.config.jsto remove the base path:
export default {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: null,
precompress: false,
strict: true,
}),
// Remove or comment out paths.base
},
};
- Rebuild and push:
npm run build
git add .
git commit -m "Add custom domain"
git push
DNS Propagation
DNS changes can take up to 48 hours to propagate globally. Use DNSChecker to monitor propagation.
Manual Deployment (Alternative)
If you prefer manual deployment or need to deploy from your local machine:
Option 1: GitHub CLI
# Install gh CLI if not already installed
# https://cli.github.com/
# Build and create release
npm run build
cd build
git init
git add .
git commit -m "Deploy to GitHub Pages"
git branch -M gh-pages
git remote add origin https://github.com/yourusername/repo-name.git
git push -f origin gh-pages
Option 2: npm deploy Script
If your package.json has a deploy script configured:
npm run deploy
Note: The automated workflow is recommended for most users as it deploys automatically on every push.
Environment Variables
GitHub Pages deployments are static, so environment variables must be set at build time.
Adding Environment Variables
- Go to Settings → Secrets and variables → Actions
- Click New repository secret
- Add your secrets (e.g.,
API_KEY,SITE_URL)
Using in Workflow
Update the workflow to use environment variables:
- name: Build site
run: npm run build
env:
PUBLIC_API_KEY: ${{ secrets.API_KEY }}
PUBLIC_SITE_URL: ${{ secrets.SITE_URL }}
Access in SvelteKit
import { env } from '$env/static/public';
const apiKey = env.PUBLIC_API_KEY;
Important: Only use PUBLIC_ prefix for client-side variables. Never expose sensitive data.
Updating Your Site
To update your deployed site:
- Make changes locally
- Test with
npm run dev - Commit and push:
git add .
git commit -m "Update content"
git push
The workflow automatically rebuilds and deploys your changes within 1-2 minutes.
Troubleshooting
Build Fails in GitHub Actions
Check the workflow logs:
- Go to Actions tab
- Click on the failed workflow
- Review the error messages
Common issues:
- Missing dependencies → Ensure
package.jsonis committed - Build errors → Test
npm run buildlocally first - Node version mismatch → Workflow uses Node 20 by default
Site Not Updating
- Check that the workflow completed successfully (Actions tab)
- Wait a few minutes for GitHub Pages to update
- Clear your browser cache (Ctrl/Cmd + Shift + R)
- Check that you pushed to the
mainbranch
404 Errors
If using repository-based deployment (username.github.io/repo-name):
- Ensure
paths.baseis set correctly insvelte.config.js - Verify the base path matches your repository name
If using custom domain:
- Check DNS records are correctly configured
- Ensure
CNAMEfile exists instatic/folder - Verify custom domain is set in repository settings
Images Not Loading
- Ensure images are in the
static/folder, notsrc/ - Use paths starting with
/(e.g.,/img/avatar.png) - If using base path, ensure images are referenced correctly
Workflow Permission Errors
If you get permission errors:
- Go to Settings → Actions → General
- Under Workflow permissions, select Read and write permissions
- Click Save
Performance & Optimization
Your site is automatically optimized during build:
✓ Pre-rendered HTML — Fast initial load ✓ Minified JS/CSS — Smaller file sizes ✓ Code splitting — Only loads what's needed ✓ Static generation — No server required
Further Optimization
Compress images:
Enable caching: GitHub Pages automatically sets cache headers for optimal performance.
Monitor performance:
- Use Lighthouse in Chrome DevTools
- Test on PageSpeed Insights
Alternative Platforms (Optional)
While Personal Landing is optimized for GitHub Pages, it works with any static hosting provider:
Vercel
- Import repository at vercel.com
- Vercel auto-detects SvelteKit
- Click Deploy
Netlify
- Import repository at netlify.com
- Build command:
npm run build - Publish directory:
build - Click Deploy
Cloudflare Pages
- Connect repository at dash.cloudflare.com
- Build command:
npm run build - Build output:
build - Deploy
All platforms support custom domains and automatic SSL certificates.
Need Help?
- GitHub Pages Docs: docs.github.com/pages
- GitHub Actions Docs: docs.github.com/actions
- SvelteKit Deployment: kit.svelte.dev/docs/adapters