A single GitHub Pages repository can host many games, each in its own subfolder. Each folder with an index.html becomes its own URL path.
๐ Repository Structure
Using your example repo โ github.com/softhints/games:
games/
โโโ index.html โ optional landing page with links to games
โโโ tetridle/
โ โโโ index.html โ Tetris game
โโโ chess/
โโโ index.html โ Chess game
๐ How URLs Map to Folders
| File in repo | Live URL |
|---|---|
index.html |
https://softhints.github.io/games/ |
tetridle/index.html |
https://softhints.github.io/games/tetridle/ |
chess/index.html |
https://softhints.github.io/games/chess/ |
Key rule: every game's file must be named exactly index.html inside its own folder. GitHub Pages serves the index.html of any folder automatically.
๐ Setup (One-Time)
- Create a public repo on GitHub (e.g.
games). - Add folders + files โ for each game, create a folder and upload its main file renamed to
index.html. You can drag-and-drop directly on GitHub's web UI ("Add file โ Upload files"). - Commit the changes.
- Enable Pages:
- Repo โ Settings โ Pages (left sidebar)
- Source: Deploy from a branch
- Branch:
mainยท Folder:/ (root) - Click Save
- Wait ~1 minute โ the live URL appears at the top of the Pages settings page.
โ Adding a New Game Later
- Create a new folder (e.g.
snake/). - Upload your game file as
snake/index.html. - Commit โ the game is instantly live at
https://softhints.github.io/games/snake/
No need to touch Pages settings again.
โ๏ธ Updating an Existing Game
Just re-upload the file (replacing the old index.html in that folder) and commit. Pages rebuilds automatically within a minute or two.
๐ Optional: Landing Page
A simple root index.html to link to all games:
<!DOCTYPE html>
<html>
<head><title>Games</title></head>
<body style="font-family:sans-serif;padding:40px;background:#1a1c21;color:#e9e2d7">
<h1>๐ฎ Games</h1>
<ul style="line-height:2;font-size:18px">
<li><a href="./tetridle/" style="color:#ffc454">Tetridle</a></li>
<li><a href="./chess/" style="color:#ffc454">Chess</a></li>
</ul>
</body>
</html>
๐ก Pro Tip โ Cleaner URL
Name the repo exactly your-username.github.io (e.g. softhints.github.io). Then games live at:
https://your-username.github.io/tetridle/https://your-username.github.io/chess/
โ ๏ธ Common Gotchas
| Issue | Fix |
|---|---|
| 404 on a game | File must be named index.html (lowercase), not Index.html or tetris.html |
| Repo must be Public | Private repos need GitHub Pro for Pages |
| Change not showing | Hard-refresh (Ctrl/Cmd+Shift+R) โ Pages caches aggressively |
| Case sensitivity | URLs are case-sensitive: /Chess/ โ /chess/ |
| Root shows 404 | Either add a root index.html, or just visit a subfolder directly |
โ Your Live Games
- Tetridle: https://softhints.github.io/games/tetridle/
- Chess: https://softhints.github.io/games/chess/
- Repo: https://github.com/softhints/games
That's it โ one repo, unlimited games, zero hosting cost. ๐