GitHub Pages: Free Hosting from This Repo
GitHub Pages serves the www/ folder as a website at
https://<username>.github.io/<repo>/. It uses the GitHub connection you already have, so
no new account or key is needed.
| Cost | Free for public repos. Private repos need GitHub Pro, Team, or Enterprise |
| Upload from Bash / GitHub Actions? | ✅ GitHub Actions, on every www/ change |
| Needs a Bash API key? | ❌ No new key. Uses the GitHub key from Guide 1 |
| Good for | The simplest extra home for the game, right next to its code |
Part 1: Turn on Pages (once)
- Repo → Settings → Pages.
- Build and deployment → Source: choose GitHub Actions.
That’s all. There’s no branch to pick, because the Action uploads www/ itself.
Part 2: Add the Action
Ask the bot:
Add a GitHub Pages deploy for www/.
It adds .github/workflows/deploy-pages.yml:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
paths: ["www/**"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: $
steps:
- uses: actions/checkout@v4
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: www
- id: deployment
uses: actions/deploy-pages@v4
The bot’s token needs Workflows: Read and write to add it (Guide 4, Part 1).
Part 3: Open the game
After the first run, the address shows in Settings → Pages and in the run summary:
https://<username>.github.io/<repo>/
The game lives in a subfolder (
/<repo>/), so it must use relative paths (./game.js, not/game.js). The sample game already does.
Troubleshooting
| Problem | Fix |
|---|---|
| “Get Pages site failed” / Pages not enabled | Do Part 1: Source → GitHub Actions. |
| Pages option missing on a private repo | Make the repo public, or use a paid plan. |
| 404 for files | Use relative paths. The site is served from /<repo>/. |
| Old version showing | Wait about a minute and hard refresh. Pages caches briefly. |
Checklist
- Repo is public (or on a paid plan)
- Settings → Pages → Source: GitHub Actions
deploy-pages.ymladded- Game opens at
https://<username>.github.io/<repo>/