Host HTML Website on GitHub Pages: A Step-by-Step Guide

Ann Jul 09, 2026

Looking to showcase your HTML skills to the world? GitHub Pages is an excellent, free, and easy-to-use platform to host your HTML website. It's perfect for portfolios, personal projects, or even simple business sites. Let's dive into a step-by-step guide on how to host your HTML website on GitHub Pages.

How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages

Before we begin, ensure you have the following: an HTML file (index.html), a GitHub account, and a basic understanding of Git and the command line. If you're not familiar with Git, don't worry; we'll guide you through the essentials.

Host Websites Free with GitHub Pages 🚀💻
Host Websites Free with GitHub Pages 🚀💻

Setting Up Your GitHub Repository

First, let's create a repository for your HTML website on GitHub.

a person pointing at a computer screen with the words build and host your website free on github
a person pointing at a computer screen with the words build and host your website free on github

1. Log in to your GitHub account and click the '+' icon in the top-right corner. Select 'New repository'.

Naming Your Repository

How to: Free Website Hosting + Custom Domain with Github Pages
How to: Free Website Hosting + Custom Domain with Github Pages

Name your repository in the format 'yourusername.github.io', replacing 'yourusername' with your GitHub username. This is crucial for GitHub Pages to recognize your repository as a website.

For example, if your GitHub username is 'johndoe', your repository name should be 'johndoe.github.io'.

Initializing Your Local Repository

three screens showing different types of webpages and the same type of website page
three screens showing different types of webpages and the same type of website page

Now, let's initialize a local Git repository for your HTML files.

1. Navigate to your project folder in the command line.

2. Initialize a new Git repository by typing 'git init'.

Host a website in under 2 minutes (Github Pages)
Host a website in under 2 minutes (Github Pages)

3. Add your HTML files to the repository using 'git add .'.

4. Commit your changes with a meaningful commit message, e.g., 'Initial commit'.

Host Your Website FREE on GitHub in 60 Seconds!
Host Your Website FREE on GitHub in 60 Seconds!
Article
Article
Host a static website for FREE on GitHub
Host a static website for FREE on GitHub
How to Host a Website On Github
How to Host a Website On Github
How To Host Website On Github in 5 minutes | Free Hosting
How To Host Website On Github in 5 minutes | Free Hosting
How to have a Free Website on GitHub | موقع الإلكتروني مجاني
How to have a Free Website on GitHub | موقع الإلكتروني مجاني
resume hosting on github in 5 minutes free templates - jolieanoo
resume hosting on github in 5 minutes free templates - jolieanoo
10xDEV - Blog
10xDEV - Blog
Create a New Github Account – Host a Website
Create a New Github Account – Host a Website
How to Publish Website on Github Pages in Three Simple Steps
How to Publish Website on Github Pages in Three Simple Steps
GitHub Pages
GitHub Pages
Bhagavad Gita Digital Copy, Magento Website Development Tips, Portfolio Website, Portfolio
Bhagavad Gita Digital Copy, Magento Website Development Tips, Portfolio Website, Portfolio
How to Upload Your Startup Website to GitHub Pages
How to Upload Your Startup Website to GitHub Pages
Host Your Own Webapp, Personal Nameplate, or Personal Website For Free in Seconds at Github
Host Your Own Webapp, Personal Nameplate, or Personal Website For Free in Seconds at Github
How to host a website with Github
How to host a website with Github
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
Set Up a Custom Domain for Your GitHub Pages
Set Up a Custom Domain for Your GitHub Pages
stunning github
stunning github
How to Make a Website From Scratch With Domain and Hosting
How to Make a Website From Scratch With Domain and Hosting
How to Use GitHub for hosting JavaScript and CSS files through Rawgit
How to Use GitHub for hosting JavaScript and CSS files through Rawgit

Connecting Your Local Repository to GitHub

Next, we'll connect your local repository to the GitHub repository you created earlier.

1. Copy the repository URL from your GitHub repository page. It should look something like this: 'https://github.com/yourusername/yourusername.github.io.git'.

Adding the Remote Repository

2. In your command line, add the remote repository using 'git remote add origin your-repository-url'. Replace 'your-repository-url' with the URL you copied earlier.

3. Push your local changes to the GitHub repository using 'git push -u origin main'. If you're using the 'master' branch instead of 'main', replace 'main' with 'master'.

Enabling GitHub Pages

1. Go to your GitHub repository page. Click on the 'Settings' tab at the top.

2. Scroll down to the 'GitHub Pages' section. Under 'Source', select 'main' (or 'master') branch. Click 'Save'.

3. It may take a few minutes for GitHub to process your website. Once it's live, you'll see a message with your website's URL under the 'Your site is published at' heading.

Customizing Your GitHub Pages Domain

By default, your website's URL will be 'https://yourusername.github.io'. If you'd like a custom domain, follow these steps:

1. Go to your GitHub repository settings and scroll down to the 'Pages' section.

2. Under 'Custom domain', enter your desired domain name. If you have a domain name, you'll need to update your DNS settings with your domain registrar to point to GitHub's servers.

Adding a CNAME File

3. To verify your custom domain, create a file named 'CNAME' (all caps) in your repository's root directory. Add your custom domain name to this file, e.g., 'yourdomain.com'.

4. Commit and push this change to your GitHub repository. It may take a few minutes for the changes to take effect.

Congratulations! You've successfully hosted your HTML website on GitHub Pages. Now, you can share your site with the world and start building your online presence. Happy coding!