GitHub Pages Deployment Configuration

GitHub Pages deployment with static site generators has three independently-failing configuration points — workflow file location, CNAME record, and site URL in the build config — and all three must be correct simultaneously. A deploy that "almost works" is usually missing exactly one of these.

Tags

GitHub Pages Deployment Configuration

The Lesson

GitHub Pages deployment with static site generators has three independently-failing configuration points — workflow file location, CNAME record, and site URL in the build config — and all three must be correct simultaneously. A deploy that "almost works" is usually missing exactly one of these.

Context

An Astro 5 static site was being deployed to GitHub Pages with a custom domain (data-readiness.johnboen.com). The project used a GitHub Actions workflow for building and deploying. The site structure placed the Astro project in a subdirectory (github/_hub/) rather than at the repository root, which created a mismatch between where files were expected and where they actually lived.

What Happened

  1. The initial deploy workflow was placed at github/_hub/.github/workflows/deploy.yml — inside the Astro project's directory structure, mirroring a convention from development.
  2. GitHub Actions only discovers workflows at .github/workflows/ relative to the repository root. The workflow never triggered because GitHub couldn't find it.
  3. The CNAME file in public/ contained a placeholder or incorrect domain, causing the custom domain configuration to fail even after the workflow was moved.
  4. The site field in astro.config.mjs pointed to the wrong URL, which caused Astro to generate incorrect absolute URLs for canonical links, sitemaps, and asset paths.
  5. The fix addressed all three in one commit: moved the workflow to .github/workflows/deploy.yml (repo root), corrected the CNAME to data-readiness.johnboen.com, and updated astro.config.mjs with the correct site URL.

Key Insights

Applicability

Applies to any static site deployed to GitHub Pages, especially with custom domains and subdirectory project layouts. The specific triple-dependency pattern (CI location, domain config, build URL) also applies to Netlify, Vercel, and Cloudflare Pages, though the configuration files differ. Less relevant for platforms with zero-config deploys (e.g., Vercel with framework auto-detection at repo root).

Related Lessons