Astro on GitHub Pages: four things that tripped me up
A blank live site, a Node version floor, search that only exists after a build, and when you need a base path.
I rebuilt this site with Astro and deployed it to GitHub Pages. These four things cost me time.
1. “Deploy from a branch” serves your source, not your build. The repository was set to Deploy from a branch → main / (root). GitHub ran its default Jekyll build on the repo root, rendered an empty README.md, and the live site was blank. For any generator that builds into a folder (dist/, _site/), switch the Pages source to GitHub Actions and upload the build output as an artifact:
gh api -X PUT repos/OWNER/REPO/pages -f build_type=workflow2. Astro 7.4 needs a newer Node 22 than you might have. astro@7.4 declares "node": ">=22.23.4" and refuses to start below that:
Node.js v22.22.2 is not supported by Astro!Please upgrade Node.js to a supported version: ">=22.23.4"I pinned Node 24 in .nvmrc and point actions/setup-node at the same file, so local and CI can’t drift.
3. Pagefind indexes the built HTML. Search only exists after astro build && pagefind --site dist, so it is empty under astro dev. Run npm run build && npm run preview to test it locally. Add data-pagefind-body to your article wrapper so navigation and footers stay out of the index.
4. base is only for project sites. A user site (<user>.github.io) is served from the domain root and needs no base. A project site lives at /<repo>/ and needs base: '/<repo>', plus links that respect it.