A repository on GitHub becomes a website in a few clicks. That’s GitHub Pages. No server to rent, no files to transfer.
The setup
We’ll use the repository you pushed in the previous lesson.
- Open your repository on GitHub
- Click Settings in the top menu
- Choose Pages in the left menu
- Under Source, choose “Deploy from a branch”
- Under Branch, choose
mainand the folder/ (root), then Save
That’s it. Wait a moment, reload, and your public URL appears near the top.
https://username.github.io/repository-name/Open it, see your page, and you’re published. Anyone in the world can now reach it.
Updating means pushing
Once published, editing locally and pushing updates the live site automatically.
git add .
git commit -m "Rewrite the profile text"
git pushNo file transfer step — that’s the big win of publishing through Git. The loop becomes: change it, record it, and it goes live.
Three reasons a page comes up blank or 404
Check these in order.
1. index.html isn’t at the top level
GitHub Pages serves the index.html at the top level of your repository as the home page.
my-site/
├── index.html ← it needs to be here
├── style.css
└── images/Tuck it away in src/index.html and there’s no home page to find, so you get a 404.
2. Capitalization doesn’t match
This is the most common cause. Windows and macOS treat filenames case-insensitively, so Style.css works on your machine. GitHub Pages’ server is strict about it, and that’s where things fall apart.
<!-- Works locally, fails once published -->
<link rel="stylesheet" href="Style.css">
<img src="images/Shima.PNG">Keeping all filenames lowercase is the safe habit.
3. Your paths are absolute
A path starting with / means “from the very top of the site.” Since GitHub Pages URLs include the repository name, that shifts everything out of place.
<!-- Breaks -->
<link rel="stylesheet" href="/style.css">
<!-- Safe -->
<link rel="stylesheet" href="style.css">TipsHow to read and write pathsIf paths are where you keep getting stuck, this article sorts them outCheck what you’re publishing
In a public repository, everything is visible to everyone — not just your HTML, but any notes or test images sitting in the folder. Before publishing, take one look through the repository on GitHub’s page view.
Git & GitHub.gitignore — deciding what not to recordKeeping the things that shouldn’t be there out from the startHow it compares to the alternatives
| GitHub Pages | Netlify / Cloudflare Pages | |
|---|---|---|
| Best when | Your work is already on GitHub | You want to publish without using Git |
| Publishing | A few clicks in settings | Drag and drop, or push |
| Updating | Automatic on push | Drag and drop, or automatic on push |
If you’ve learned Git, GitHub Pages is the least work.
TipsHow to publish your site on the internetA comparison that includes drag-and-drop publishingSummary of this lesson
- Settings → Pages → set the branch to
mainand save. That’s the whole setup - Updating is just
git push— no transfer step - When nothing shows, check where index.html is, filename capitalization, and your paths