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

Ann Jul 09, 2026

Ever wanted to showcase your web projects or personal portfolio online without the hassle of setting up a web server? GitHub Pages, a static site hosting service, is an excellent solution. It's free, easy to use, and integrates seamlessly with your GitHub repository. Let's delve into how you can host your HTML file on GitHub Pages.

Host Websites Free with GitHub Pages ๐Ÿš€๐Ÿ’ป
Host Websites Free with GitHub Pages ๐Ÿš€๐Ÿ’ป

Before we begin, ensure you have a GitHub account and basic understanding of Git and HTML. If you're new to these, don't worry; we'll keep the guide beginner-friendly.

Host Your Website FREE on GitHub in 60 Seconds!
Host Your Website FREE on GitHub in 60 Seconds!

Setting Up Your Repository

First, you need to create a new repository on GitHub. Name it after your desired username, like 'yourusername.github.io'. This will be the URL where your website will be hosted.

How to use GitHub as a CDN to Host Static Files and Images
How to use GitHub as a CDN to Host Static Files and Images

Initialize a local Git repository in your project folder and connect it to your GitHub repository. You can do this using the following commands in your terminal:

Initializing and Connecting Local Repository

How to Use GitHub for hosting JavaScript and CSS files through Rawgit
How to Use GitHub for hosting JavaScript and CSS files through Rawgit

Open your terminal, navigate to your project folder, and initialize a local Git repository:

git init

Then, connect it to your GitHub repository:

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

git remote add origin https://github.com/yourusername/yourusername.github.io.git

Adding and Committing Your HTML File

Add your HTML file to the Git repository:

GitHub - CrazeDoc/Cheatsheets-for-Developers: ๐Ÿ“Š Get all of my CSS Cheatsheets from here which I have created & shared on twitter. Thanks for the support. ๐Ÿ’œ
GitHub - CrazeDoc/Cheatsheets-for-Developers: ๐Ÿ“Š Get all of my CSS Cheatsheets from here which I have created & shared on twitter. Thanks for the support. ๐Ÿ’œ

git add index.html

Then, commit it with a meaningful commit message:

login form html css
login form html css
โœ… Create Lists in HTML
โœ… Create Lists in HTML
How to Easily Host Files on GitHub
How to Easily Host Files on GitHub
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
Login and Registration Form in HTML & CSS
Login and Registration Form in HTML & CSS
An Apple-style layout focuses on clarity, spacing, and logical hierarchy, making your content
An Apple-style layout focuses on clarity, spacing, and logical hierarchy, making your content
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
Github Cheatsheet
Github Cheatsheet
GitHub Is Pushed to Suspend the Account of a Kodi Add-On Developer
GitHub Is Pushed to Suspend the Account of a Kodi Add-On Developer
an image of a web page with the word hover me in purple and black
an image of a web page with the word hover me in purple and black
่‡ช่บซใฎใ‚ตใƒผใƒ“ใ‚นใ‚„ๅ•†ๅ“ใ‚’ๆŠ•็จฟใ—ใฆใ‚‚ใ‚‰ใ†๏ผInstagramใฎUGC็ฒๅพ—ๆ–นๆณ•ใจใฏ๏ผŸ
่‡ช่บซใฎใ‚ตใƒผใƒ“ใ‚นใ‚„ๅ•†ๅ“ใ‚’ๆŠ•็จฟใ—ใฆใ‚‚ใ‚‰ใ†๏ผInstagramใฎUGC็ฒๅพ—ๆ–นๆณ•ใจใฏ๏ผŸ
๐™ƒ๐™๐™ˆ๐™‡ ๐™๐™–๐™œ๐™จ ๐™˜๐™๐™š๐™–๐™ฉ ๐™จ๐™๐™š๐™š๐™ฉ
๐™ƒ๐™๐™ˆ๐™‡ ๐™๐™–๐™œ๐™จ ๐™˜๐™๐™š๐™–๐™ฉ ๐™จ๐™๐™š๐™š๐™ฉ
Basics of HTML
Basics of HTML
two screens showing different types of web pages
two screens showing different types of web pages
Embedding Images in HTML using <img>
Embedding Images in HTML using <img>
html and css login form
html and css login form
'X0.at Filehost' that allows you to easily share files with the cURL command for free
'X0.at Filehost' that allows you to easily share files with the cURL command for free
HTML Document Structure
HTML Document Structure

git commit -m "Initial commit of index.html"

Enabling GitHub Pages

Now, let's enable GitHub Pages for your repository.

In your GitHub repository, click on the 'Settings' tab at the top. Scroll down to the 'GitHub Pages' section. Under 'Source', select 'main' branch (or your primary branch name) and click 'Save'.

Choosing the Right Branch

By default, GitHub Pages serves content from the 'main' branch. If you've used a different name for your primary branch, ensure you select that here.

Accessing Your Live Website

After a few minutes, your website should be live at https://yourusername.github.io. You can replace 'yourusername' with your actual GitHub username.

Congratulations! You've successfully hosted your HTML file on GitHub Pages. Now, whenever you push changes to your 'main' branch, they'll be reflected on your live website. Happy coding!