How to Add HTML to GitHub Pages

Ann Jul 09, 2026

Embarking on your web development journey often involves using GitHub Pages for hosting your projects. To make the most of this platform, you'll need to know how to add HTML to GitHub Pages. Let's dive into a step-by-step guide to help you get started.

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

Before we begin, ensure you have a basic understanding of HTML and Git. If you're new to these, consider taking some online courses to familiarize yourself with their fundamentals.

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

Setting Up Your GitHub Pages Repository

Your first step is to create a repository specifically for your GitHub Pages. This repository will contain all the HTML, CSS, and JavaScript files for your website.

How to Use GitHub: Essential Tips and Tricks for Developers
How to Use GitHub: Essential Tips and Tricks for Developers

To create a repository, log in to your GitHub account, click the '+' icon in the top-right corner, and select 'New repository'. Name your repository in the following format: 'yourusername.github.io', replacing 'yourusername' with your GitHub username.

Initializing Your Repository Locally

HTML input types
HTML input types

Next, initialize your repository locally on your computer. Open your terminal or command prompt, navigate to the directory where you want to create your project, and type:

git init

This command initializes a new Git repository. Now, you can start adding files to your project.

Creating Your Index.html File

the ultimate guide to creating and formating tags
the ultimate guide to creating and formating tags

Create a new file named 'index.html' in your project directory. This file will serve as the main page of your GitHub Pages website. You can add your HTML code to this file.

For example, let's add a simple HTML structure:

<!DOCTYPE html>
<html>
<head>
<title>My GitHub Pages</title>
</head>
<body>
<h1>Welcome to My GitHub Pages</h1>
</body>
</html>

Connecting Your Repository to GitHub Pages

HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners
HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners

Now that you have your local repository set up, it's time to connect it to GitHub Pages. This will allow you to host your website on the platform.

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

How to create a website using html
How to create a website using html
Embedding Images in HTML using <img>
Embedding Images in HTML using <img>
Basics of HTML
Basics of HTML
a red and black text description for a web page with an arrow pointing to it
a red and black text description for a web page with an arrow pointing to it
Add Watermark With HTML & CSS
Add Watermark With HTML & CSS
Github Cheatsheet
Github Cheatsheet
an image of the back side of a computer screen with text that reads, add css to html
an image of the back side of a computer screen with text that reads, add css to html
GitHub Profile Setup Guide for Engineering Students πŸš€
GitHub Profile Setup Guide for Engineering Students πŸš€
4 Ways To Add Icons In HTML & CSS
4 Ways To Add Icons In HTML & CSS
an image of a web page with the text'html inputt types '
an image of a web page with the text'html inputt types '
How to Build a GitHub Portfolio That Gets Noticed
How to Build a GitHub Portfolio That Gets Noticed
How To Build A Tribute Page (freeCodeCamp Challenge)
How To Build A Tribute Page (freeCodeCamp Challenge)
Git and GitHub Commands PDF - Complete Guide for Beginners to ProπŸš€πŸ’»  #git #command #code
Git and GitHub Commands PDF - Complete Guide for Beginners to ProπŸš€πŸ’» #git #command #code
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
Basic HTML Tags
Basic HTML Tags
Add CSS In HTML
Add CSS In HTML
a handwritten diagram with the words html and an image of a computer screen on it
a handwritten diagram with the words html and an image of a computer screen on it
login form html css
login form html css

Pushing Your Changes to GitHub

After making changes to your 'index.html' file or adding new files, you need to push these changes to your GitHub repository. Here's how:

  1. Add your changes to the Git staging area using the command: git add .
  2. Commit your changes with a meaningful commit message using: git commit -m "Your commit message"
  3. Push your changes to the remote repository using: git push origin main (or 'master')

Your changes should now be live on your GitHub Pages website. You can access it by visiting 'http://yourusername.github.io'.

Updating Your GitHub Pages

Whenever you make changes to your local repository, follow the same process of adding, committing, and pushing your changes to GitHub. Your GitHub Pages website will automatically update with your latest changes.

That's it! You now know how to add HTML to GitHub Pages and keep your website up-to-date. Happy coding!