How to Publish HTML Website on GitHub

Ann Jul 09, 2026

Publishing an HTML website on GitHub is a straightforward process that allows you to showcase your web development projects, collaborate with others, and even host your site for free. Here's a step-by-step guide to help you achieve this.

Host Websites Free with GitHub Pages πŸš€πŸ’»
Host Websites Free with GitHub Pages πŸš€πŸ’»

Before we dive in, ensure you have the following: an HTML file (or multiple files if it's a larger project), a GitHub account, and Git installed on your local machine. If you haven't installed Git, you can download it from the official website: git-scm.com/downloads.

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

Setting Up Your GitHub Repository

First, you'll need to create a repository on GitHub to host your website. A repository, or repo, is like a project folder where your files are stored and tracked.

How to Publish Website on Github Pages in Three Simple Steps
How to Publish Website on Github Pages in Three Simple Steps

To create a new repository:

  1. Log in to your GitHub account.
  2. Click the '+' icon in the top-right corner and select 'New repository'.
  3. Name your repository (e.g., 'my-website'), write a short description, and then click 'Create repository'.
Host Your Website FREE on GitHub in 60 Seconds!
Host Your Website FREE on GitHub in 60 Seconds!

Initializing Git Locally

Now, let's initialize Git in your local project folder. This tells Git to start tracking changes in your files.

Open your terminal or command prompt, navigate to your project folder, and type:

How to create a website using html
How to create a website using html

git init

You should see a new folder named '.git' appear in your project folder.

Adding and Committing Your Files

Next, you'll add your HTML files to Git and commit them. This is like saving a snapshot of your project.

an image of a web page with the text'html input types'on it
an image of a web page with the text'html input types'on it

To add your files, type:

git add .

Then, to commit your changes, type:

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
a screen shot of a web page with the words'html input types '
a screen shot of a web page with the words'html input types '
How to Make a Website From Scratch With Domain and Hosting
How to Make a Website From Scratch With Domain and Hosting
Learning HTML for Beginners: Easy Steps to Master Web Design
Learning HTML for Beginners: Easy Steps to Master Web Design
🌐 How Websites Work – A Beginner’s Guide
🌐 How Websites Work – A Beginner’s Guide
HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners
HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners
Getting Started with HTML Basics: Web Development for Beginners
Getting Started with HTML Basics: Web Development for Beginners
Modern GitHub Profile UI
Modern GitHub Profile UI
18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills
18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills
Basics of HTML
Basics of HTML
the top 10 best practices for html to help you improve your site's performance and seo
the top 10 best practices for html to help you improve your site's performance and seo
the ultimate guide to creating and formating tags
the ultimate guide to creating and formating tags
πŸ’» 5 HTML Tips Every Beginner Should Know .
πŸ’» 5 HTML Tips Every Beginner Should Know .
🌍 Designing, Building, and Publishing Websites
🌍 Designing, Building, and Publishing Websites
login form html css
login form html css
Create A Website Like YouTube Using HTML CSS JS | YouTube Clone Website Design Step By Step
Create A Website Like YouTube Using HTML CSS JS | YouTube Clone Website Design Step By Step
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
How To Build A Tribute Page (freeCodeCamp Challenge)
How To Build A Tribute Page (freeCodeCamp Challenge)
HTML5 AND CSS FOR WEB DEVELOPMENT EASY | Website Making
HTML5 AND CSS FOR WEB DEVELOPMENT EASY | Website Making

git commit -m "Initial commit"

Replace "Initial commit" with a brief description of your commit.

Connecting Your Local Repository to GitHub

Now, you'll connect your local repository to the one you created on GitHub.

First, copy the remote URL of your GitHub repository. You can find this by clicking the green 'Code' button on your repository page and copying the URL in the 'Clone with HTTPS' section.

Adding the Remote Repository

In your terminal, add the remote repository URL to your local Git repository with the following command:

git remote add origin YOUR_REPO_URL

Replace 'YOUR_REPO_URL' with the URL you copied earlier.

Pushing Your Local Changes to GitHub

Finally, you'll push your local changes to the GitHub repository. This makes your website live and accessible online.

To push your changes, type:

git push -u origin main

If you're using a different branch name, replace 'main' with your branch name.

Congratulations! Your HTML website is now published on GitHub. You can access it by visiting https://github.com/yourusername/your-repo-name, replacing 'yourusername' and 'your-repo-name' with your GitHub username and repository name, respectively. To view your website, click the 'Settings' tab, scroll down to the 'GitHub Pages' section, and select the main branch as the source. Then, click 'Save'. Your website should now be live at https://yourusername.github.io/your-repo-name.

Regularly update your website by making changes locally, committing them, and pushing them to GitHub. Happy coding!