GitHub Pages Hosting Guide

Learn how to host your website for free using GitHub Pages with the correct repository naming convention

Important Note

For your personal GitHub Pages site, your repository MUST be named exactly:

username.github.io

Replace "username" with your actual GitHub username. This is a requirement from GitHub for personal sites.

Step-by-Step Guide

1

Create a GitHub Account

If you don't have one already, go to github.com and sign up for a free account.

2

Create a New Repository

Click the "+" icon in the top right corner and select "New repository".

This is the most important step: Your repository must be named username.github.io (replace "username" with your actual GitHub username)
3

Repository Settings

Make sure to:

  • Set the repository to Public (required for free GitHub Pages)
  • Initialize with a README file (optional but recommended)
4

Upload Your Website Files

Add your HTML, CSS, JavaScript, and other assets to the repository. You can:

  • Use the web interface to upload files
  • Use Git commands to push files from your computer
  • Use GitHub Desktop for a graphical interface
Your main HTML file should be named index.html for it to serve as the homepage.
5

Enable GitHub Pages

Go to your repository Settings → Pages → Select "main" branch as source → Click Save.

GitHub Pages Settings Screenshot
6

Wait for Deployment

It may take a few minutes for your site to be published. You can check the progress in the "Pages" section of your repository settings.

GitHub will show a green checkmark when your site is successfully published.
7

Visit Your Live Website

Once deployed, your website will be available at:

https://username.github.io

Remember to replace "username" with your actual GitHub username.

Pro Tips

Use a custom domain (optional) by adding a CNAME file to your repository and configuring DNS settings.
Enable HTTPS for your GitHub Pages site for secure connections (enabled by default for github.io domains).
Use GitHub Actions to automate testing and deployment of your site.
Project sites (sites for specific repositories) have different requirements and URL structures than user/organization sites.