Skip to content

Setting Up GitHub Pages - The Basics

Published:

Today I learned the fundamentals of setting up GitHub Pages for free static site hosting.

What is GitHub Pages?

GitHub Pages is a free static site hosting service that lets you publish websites directly from your GitHub repositories. Perfect for:

Real Example: SpeakEasy Documentation

Let me walk through a real setup using my SpeakEasy repository which hosts documentation at speakeasy.arach.dev.

1. Repository Structure

The SpeakEasy repo has a landing/ folder containing a Next.js app:

speakeasy/
├── landing/           (Next.js documentation site)
│   ├── app/
│   ├── components/
│   ├── package.json
│   └── next.config.mjs
├── CNAME             (custom domain: speakeasy.arach.dev)
└── .github/workflows/deploy-landing.yml

2. GitHub Actions Workflow

Instead of basic branch deployment, I use GitHub Actions for automated builds:

# .github/workflows/deploy-landing.yml
name: Deploy Landing Page
on:
  push:
    branches: [ master ]
    paths: ['landing/**']

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pages: write
      id-token: write
    
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: '20'
    - run: npm install --legacy-peer-deps
      working-directory: ./landing
    - run: npm run export
      working-directory: ./landing
    - uses: actions/configure-pages@v4
    - uses: actions/upload-pages-artifact@v3
      with:
        path: ./landing/out
    - uses: actions/deploy-pages@v4

3. Enable GitHub Pages

In repository SettingsPages:

Key Takeaways from the SpeakEasy Setup

Pro Tips

What’s Next?

Once you’ve got the basics down, check out my follow-up TIL on custom domains and subdomains using the SpeakEasy setup as an example.

GitHub Pages + GitHub Actions is incredibly powerful - perfect for documentation sites and project demos! 🚀