How to Upload HTML File to GitHub Pages

Ann Jul 09, 2026

Uploading an HTML file to GitHub Pages is a straightforward process that allows you to host your website directly from GitHub's servers. This guide will walk you through the steps to achieve this, ensuring your website is live and accessible to the world.

How to upload files in GitHub
How to upload files in GitHub

Before we dive into the process, make sure you have the following prerequisites: a GitHub account, a local HTML file, and a basic understanding of Git and GitHub.

Upload an Existing File to GitHub
Upload an Existing File to GitHub

Setting Up GitHub Pages

Your first step is to set up GitHub Pages for your repository. This will create a dedicated branch for your website and configure GitHub to serve your HTML file.

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

To do this, navigate to your repository on GitHub, click on the 'Settings' tab, and scroll down to the 'GitHub Pages' section. Select the 'main' branch (or whichever branch you want to use for your website) and click 'Save'.

Creating a Repository

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

If you haven't already, create a new repository on GitHub. Name it something like 'yourusername.github.io', where 'yourusername' is your GitHub username. This will be the URL of your live website.

After creating the repository, click on the green 'Code' button and copy the URL of the repository. You'll need this to push your local HTML file to GitHub.

Pushing Your HTML File to GitHub

File Drag & Drop Upload In HTML Javascript
File Drag & Drop Upload In HTML Javascript

Now, let's push your local HTML file to the GitHub repository. Open your terminal or command prompt, navigate to the directory containing your HTML file, and initialize a new Git repository with the following commands:

git init
git add .
git commit -m "Initial commit"

Next, connect your local repository to GitHub using the repository URL you copied earlier:

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

Finally, push your HTML file to GitHub with the following command:

Gitflow on GitHub: How to use Git Flow workflows with GitHub Based Repos
Gitflow on GitHub: How to use Git Flow workflows with GitHub Based Repos

git push -u origin main

Once the push is successful, your HTML file will be live on GitHub Pages at 'https://yourusername.github.io'.

Customizing Your GitHub Pages

login form html css
login form html css
Embedding Images in HTML using <img>
Embedding Images in HTML using <img>
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 '
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
the ultimate guide to creating and formating tags
the ultimate guide to creating and formating tags
HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners
HTML Cheat Sheet πŸ“„βœ¨ Quick Guide for Beginners
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
Basics of HTML
Basics of HTML
How to create a website using html
How to create a website using html
html and css login form
html and css login form
two screens showing different types of web pages
two screens showing different types of web pages
an email link is displayed in the form of a webpage with icons and symbols
an email link is displayed in the form of a webpage with icons and symbols
Html, Css Login Tamplates
Html, Css Login Tamplates
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
How To Build A Tribute Page (freeCodeCamp Challenge)
How To Build A Tribute Page (freeCodeCamp Challenge)
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
HTML Document Structure
HTML Document Structure
HTML INPUT TAGS | web development | computer engineering
HTML INPUT TAGS | web development | computer engineering
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

Now that your website is live, you can customize it further by adding more HTML files, CSS styles, or even JavaScript functionality.

To do this, simply add or modify files in your local repository, commit the changes, and push them to GitHub. GitHub Pages will automatically update your live website with the changes.

Adding More HTML Files

To add more pages to your website, create new HTML files in your local repository and link to them from your main HTML file. For example, if you create a new file called 'about.html', you can link to it like this:

<a href="about.html">About</a>

Then, push the new file to GitHub, and it will be live at 'https://yourusername.github.io/about.html'.

Using a Custom Domain

If you want to use a custom domain for your website instead of the GitHub Pages URL, you can do so by following GitHub's guide on configuring a custom domain. This allows you to access your website at 'www.yourdomain.com' instead of 'https://yourusername.github.io'.

And there you have it! You've successfully uploaded your HTML file to GitHub Pages and have a live website. Keep updating and customizing your website as needed, and don't forget to push your changes to GitHub to keep your live website up-to-date. Happy coding!