GitHub Pages
GitHub Pages turns a repository of HTML, CSS and JavaScript into a live website — free, with HTTPS.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Nov 25, 2026
Related tutorials
Learning objectives#
- Publish a static site with GitHub Pages
- Know the user site vs project site URLs
- Configure the source branch
- Add a custom domain
Explanation#
A repository named <username>.github.io (asha.github.io) becomes your personal site at https://asha.github.io. Any other repository can publish a project site at https://asha.github.io/<repo>/.
Settings → Pages → Build and deployment: Source “Deploy from a branch”, branch main and folder / (root) or /docs. Save. After a minute the page shows “Your site is live at …”.
Sites built with React, Angular or Vite need a build step: choose Source “GitHub Actions” and use the suggested workflow, which builds the site and publishes the output folder.
For a custom domain, enter it under Custom domain, add the DNS records GitHub shows (CNAME for www, A records for the apex) at your registrar, and tick Enforce HTTPS.
Step-by-step screens#
Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: A personal site in four commands#
git clone https://github.com/asha/asha.github.io.git
cd asha.github.io
echo "<h1>Hi, I'm Asha</h1>" > index.html
git add index.html
git commit -m "Add home page"
git push
# Settings → Pages → Deploy from a branch → main / (root) → Save
About a minute later https://asha.github.io shows “Hi, I’m Asha”. Every later push updates the site.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- The repository name decides the address.
- index.html is the home page.
- Push to main.
- Pages publishes main / (root).
Real-world use case#
A fresher hosts a portfolio on asha.github.io with links to three projects, each with its own project site and live demo.
Common mistakes#
Pages shows the README or a 404. The home page must be named index.html.
/style.css points to asha.github.io/style.css, not /hello-github/style.css. Use relative paths or set the base path in your build tool.
Best practices#
- Use relative paths
- Enforce HTTPS
- Use the Actions source for build-based sites
- Check the Actions tab if a deploy fails
Remember this#
username.github.io = personal site.
Settings → Pages → main / (root).
Every push redeploys.
Practice exercise#
Your task: Write the address of the project site for the repository hello-github owned by asha.
Show solution
https://asha.github.io/hello-github/
Mini quiz#
What must the repository be called for the site https://asha.github.io?
Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions
My notes#
Saved in this browser.