Prerequisites
Before deploying to GitHub Pages:- A GitHub account
- A GitHub repository for hosting your site
- GitHub authentication (Personal Access Token or OAuth)
- A completed build ready for deployment
Authentication Setup
Opal Editor supports multiple GitHub authentication methods:Personal Access Token (Recommended)
Create a Personal Access Token
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
- Click “Generate new token (classic)”
- Give it a descriptive name (e.g., “Opal Editor”)
- Select scopes:
repo(full control of private repositories)public_repo(for public repositories only)
- Click “Generate token”
- Copy the token immediately (it won’t be shown again)
OAuth
Alternative authentication methods:- OAuth: Browser-based authentication flow
- Device Flow: CLI-friendly authentication without browser
Destination Configuration
Configure your GitHub Pages deployment:Configuration Fields
- repository (required): GitHub repository in format
owner/repoor full URL- Examples:
username/my-siteorhttps://github.com/username/my-site - Automatically normalized to
owner/repoformat
- Examples:
- branch (required): Branch for deployment (default:
gh-pages)- Common choices:
gh-pages,main,master
- Common choices:
- baseUrl (required): Base URL path for your site
- Use
/for user/org pages (username.github.io) - Use
/repo-name/for project pages
- Use
For project repositories, the baseUrl should match your repository name:
/repo-name/Deployment Process
GitHub Pages deployment uses Git to push your built site:Configure repository
Set up your deployment:
- Specify repository (created if doesn’t exist)
- Choose deployment branch
- Set base URL for correct link paths
Build your site
Complete a build in Opal Editor:
- Files are processed and built
- HTML is generated
- Assets are prepared
Deploy via Git
Deployment process:
- Temporary Git repository is created
- Built files are committed
- Changes are force-pushed to specified branch
- Repository is cleaned up
GitHub Pages activation
GitHub automatically:
- Detects the new commit
- Builds and deploys your site
- Makes it available at the Pages URL
How It Works
The GitHub deployment process (RemoteAuthGithubAgent):- Repository Validation: Verifies repository exists or creates it
- Git Initialization: Creates a temporary Git repository
- Commit Creation: Commits all built files
- Remote Push: Force-pushes to the specified branch
- URL Generation: Returns the GitHub Pages URL
- Cleanup: Removes temporary Git repository
Git-Based Deployment
Unlike other platforms, GitHub Pages uses Git:- Force push for clean deployments
- Full file replacement each time
- No merge conflicts
- Complete deployment history
URL Rewriting
For non-root base URLs, Opal Editor automatically:- Rewrites absolute URLs in HTML files
- Updates links to include base URL
- Ensures assets load correctly
- Handles script and style references
Repository Types
User/Organization Pages
Forusername.github.io repositories:
- Must be named
username.github.io - Deploy to
mainbranch (or configure in settings) - Base URL is always
/ - Site URL:
https://username.github.io
Project Pages
For project repositories:- Any repository name
- Typically use
gh-pagesbranch - Base URL must match repo name
- Site URL:
https://username.github.io/my-project
Features
Free Hosting
GitHub Pages is completely free:- Unlimited public repositories
- 1GB storage limit
- 100GB bandwidth per month
- Custom domain support
Automatic HTTPS
All GitHub Pages sites include:- Free SSL certificates
- HTTPS enforced (optional)
- Automatic certificate renewal
Custom Domains
Configure custom domains:- Add CNAME file to your repository
- Configure DNS records
- Enable HTTPS in repository settings
Deployment History
Git-based deployment provides:- Complete commit history
- Ability to view previous versions
- Revert to earlier deployments
- Full audit trail
Troubleshooting
Repository Not Found
Solution: Verify the repository name and your access permissions.Authentication Failures
If Git push fails:- Verify Personal Access Token is valid
- Check token has
repoorpublic_reposcope - Ensure token hasn’t expired
- Try regenerating the token
404 After Deployment
If site shows 404 after deployment:- Enable GitHub Pages in repository settings
- Select correct branch (
gh-pages) - Wait a few minutes for GitHub to build
- Check repository visibility (public vs private)
- Verify branch contains
index.html
Wrong Base URL
If styles/assets don’t load:- Check
baseUrlmatches repository name - For user pages, use
/ - For project pages, use
/repo-name/ - Verify HTML contains correct URLs
Force Push Issues
Deployment uses force push:- Previous branch history is overwritten
- Don’t use the same branch for development
- Use dedicated deployment branch (
gh-pages) - Never force push to
mainif used for source code
Best Practices
- Use dedicated branch: Deploy to
gh-pages, keep code inmain - Set correct base URL: Match repository name for project pages
- Enable HTTPS: Configure in repository settings
- Add custom domain: Use CNAME for professional URLs
- Monitor deployment: Check Actions tab for GitHub’s build process
- Test locally: Ensure build completes before deploying
Advanced Configuration
Custom Domain Setup
Add a custom domain:Jekyll Override
Disable Jekyll processing: Add a.nojekyll file to your build output to prevent GitHub from processing your site with Jekyll.
404 Page
Create a custom 404 page: Add404.html to your build output. GitHub Pages will serve it for missing pages.
Deployment Workflow
For automated deployments, combine with:- GitHub Actions for CI/CD
- Webhook triggers
- Scheduled deployments
Performance Optimization
CDN
GitHub Pages uses Fastly CDN:- Global distribution
- Edge caching
- Fast content delivery
Caching
Optimize caching:- Use versioned asset filenames
- Set appropriate cache headers
- Leverage browser caching