GitHub Pages Reference
Overview
Section titled “Overview”GitHub Pages is GitHub’s free static site hosting service, perfect for:
- 📄 Personal portfolios and resumes
- 📚 Project documentation with Jekyll
- 🎨 Demo sites and prototypes
- 📝 Blogs and simple websites
Domain Configuration
Section titled “Domain Configuration”{ "owner": { "username": "username", "email": "user@example.com" }, "records": { "CNAME": "username.github.io" }}
Setup Process
Section titled “Setup Process”1. Enable GitHub Pages
Section titled “1. Enable GitHub Pages”- Go to repository Settings
- Navigate to Pages section
- Set Source to your branch (usually
main
) - Choose root directory:
/ (root)
or/docs
2. Add Custom Domain
Section titled “2. Add Custom Domain”- In Custom domain field:
username.loves-to.dev
- Click Save
- Enable “Enforce HTTPS”
- GitHub creates
CNAME
file automatically
3. Repository Structure
Section titled “3. Repository Structure”your-repo/├── index.html # Homepage (required)├── _config.yml # Jekyll config (optional)├── CNAME # Auto-generated, don't edit├── assets/│ ├── css/│ └── images/└── _posts/ # For Jekyll blogs └── 2024-01-01-hello.md
Jekyll Configuration
Section titled “Jekyll Configuration”Basic _config.yml
Section titled “Basic _config.yml”title: Your Site Titledescription: Site description for SEOurl: "https://username.loves-to.dev"baseurl: ""
# Build settingsmarkdown: kramdowntheme: minimaplugins: - jekyll-feed - jekyll-sitemap - jekyll-seo-tag
# Social linksgithub_username: usernametwitter_username: username
Supported Themes
Section titled “Supported Themes”minima
(default)jekyll-theme-cayman
jekyll-theme-minimal
jekyll-theme-modernist
- More themes →
Custom Domain Setup
Section titled “Custom Domain Setup”DNS Verification
Section titled “DNS Verification”# Check if domain resolvesnslookup username.loves-to.dev
# Should return Cloudflare IPs:# 104.16.132.229# 104.16.133.229
SSL Certificate
Section titled “SSL Certificate”- Automatic: GitHub provisions SSL within 24 hours
- Verification: Look for green padlock in browser
- Force HTTPS: Always enable this option
File Limits & Restrictions
Section titled “File Limits & Restrictions”Limit | Value |
---|---|
Repository size | 1 GB recommended |
File size | 100 MB max |
Monthly bandwidth | 100 GB soft limit |
Build time | 10 minutes max |
Jekyll Build Process
Section titled “Jekyll Build Process”Automatic Builds
Section titled “Automatic Builds”- Triggered on every push to source branch
- Build logs available in Actions tab
- Failed builds send email notifications
Local Development
Section titled “Local Development”# Install Jekyllgem install bundler jekyll
# Create new sitejekyll new my-site
# Serve locallybundle exec jekyll serve# Visit http://localhost:4000
Common Issues
Section titled “Common Issues”Build Failures
Section titled “Build Failures”# Check _config.yml syntaxplugins: - jekyll-feed # Correct - jekyl-feed # Wrong - typo
CNAME File Conflicts
Section titled “CNAME File Conflicts”- Don’t manually edit
CNAME
file - Let GitHub manage it automatically
- Conflicts cause domain verification to fail
404 Errors
Section titled “404 Errors”- Ensure
index.html
orindex.md
exists - Check file naming (case-sensitive)
- Verify Jekyll front matter syntax
Advanced Features
Section titled “Advanced Features”Custom 404 Page
Section titled “Custom 404 Page”---layout: defaultpermalink: /404.html---
<h1>Page Not Found</h1><p>Sorry, the page you're looking for doesn't exist.</p>
GitHub Actions Integration
Section titled “GitHub Actions Integration”name: Deploy to GitHub Pages
on: push: branches: [ main ]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '18' - run: npm install - run: npm run build - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist