Deploy guide
How to deploy Gatsby to GitHub Pages
The base path, a workflow file to copy and the one setting to switch: Gatsby on GitHub Pages, built on every push.
Checked 16 October 2026
In short
The settings
- Pages source
- Build
- Folder it publishes
- Live at
Step by step
Set it up
- 1
Set the base path
A GitHub Pages project site lives in a subfolder, USERNAME.github.io/REPO, so the build has to know that folder's name.
Add a
pathPrefixwith the repository name. The workflow builds with--prefix-pathsso Gatsby uses it.gatsby-config.js module.exports = { pathPrefix: '/REPO', // ...your siteMetadata and plugins }; - 2
Add the workflow
Create
.github/workflows/deploy.ymlin the repository with the file below. It builds the site on every push to main and publishes the result..github/workflows/deploy.yml name: Deploy to GitHub Pages on: push: branches: [main] workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version: lts/* cache: npm - id: pages uses: actions/configure-pages@v6 - run: npm ci - name: Build run: npx gatsby build --prefix-paths - uses: actions/upload-pages-artifact@v5 with: path: public deploy: needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - id: deployment uses: actions/deploy-pages@v5 - 3
Switch Pages to GitHub Actions
In the repository on GitHub, open the Pages settings and set the source to GitHub Actions. This is a one-time switch.
Settings→Pages→Build and deployment→Source: GitHub Actions
- 4
Push, then open your site
Commit and push to main. The Actions tab shows the build; when it turns green, the site is at https://USERNAME.github.io/REPO/. Every push after that deploys again.
Good to know
Common snags
- The workflow uses npm. With pnpm or Yarn, change the install line and the cache setting to match.
Stuck? The usual problems, solved
Questions
Before you start
Why does my site load without its styles?
The pages are looking for their files at the root of USERNAME.github.io instead of in /REPO/. Check the base path setting in step one matches the repository name exactly, including capitals.
Is GitHub Pages free?
Free for public repositories. Private repositories need a paid GitHub plan. A Pages site is public, even when it is built from a private repository.
How do I use my own domain?
Add it in Settings → Pages → Custom domain, then add the DNS records at your registrar (our custom domain guides have them per registrar). With your own domain the site is at the root again, so remove the base path setting.
Next step: connect your own domain to GitHub Pages.
Rather skip git and build settings?
Build on your computer with npm run build, then drop the public folder (or a zip of it) on 99helpers. It's online at its own address in seconds, with no repository, workflow or base path to set up. Passwords, analytics, your own domain and AI editing are built in.
Or skip the setup
Drop it in. It's online in seconds.
A file, a folder or a whole site: 99helpers puts it online at its own address, with no git, no build settings and no DNS to start with. Add your own domain whenever you're ready.