Deploy HTML to GitHub Pages: A Step-by-Step Guide

Ann Jul 09, 2026

Deploying an HTML website on GitHub Pages is a straightforward process that allows you to showcase your projects or portfolio online. GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository and serves them over the web. Here's a comprehensive guide on how to deploy your HTML website on GitHub Pages.

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

Before we dive into the process, ensure you have the following prerequisites: an HTML website ready to deploy, a GitHub account, and a basic understanding of Git and GitHub.

GitHub Profile
GitHub Profile

Setting Up Your GitHub Pages Repository

To start, you'll need to create a repository specifically for your GitHub Pages site. This repository should have the same name as your GitHub username, followed by '.github.io'. For example, if your GitHub username is 'johndoe', your repository should be named 'johndoe.github.io'.

GitHub - peaceiris/actions-gh-pages: GitHub Actions for GitHub Pages πŸš€ Deploy static files and publish your site easily. Static-Site-Generators-friendly.
GitHub - peaceiris/actions-gh-pages: GitHub Actions for GitHub Pages πŸš€ Deploy static files and publish your site easily. Static-Site-Generators-friendly.

Once your repository is created, you can initialize a local Git repository in your project folder and add your HTML files. Then, push these files to the 'main' branch of your GitHub Pages repository.

Initializing a Local Git Repository

GitHub - gitname/react-gh-pages: Deploying a React App (created using create-react-app) to GitHub Pages
GitHub - gitname/react-gh-pages: Deploying a React App (created using create-react-app) to GitHub Pages

In your terminal, navigate to your project folder and initialize a new Git repository with the command 'git init'. Then, add your HTML files to the repository using 'git add .'.

Commit your changes with a meaningful commit message using 'git commit -m "Initial commit"'. Now, your local repository is ready to be pushed to GitHub.

Pushing Your HTML Files to GitHub

Deploying React Apps: A Guide to Using GitHub Pages
Deploying React Apps: A Guide to Using GitHub Pages

First, create a remote repository on GitHub as described above. Then, connect your local repository to this remote repository using 'git remote add origin https://github.com/yourusername/yourusername.github.io.git'. Replace 'yourusername' with your actual GitHub username.

Push your local changes to the remote repository using 'git push -u origin main'. This command will push your HTML files to the 'main' branch of your GitHub Pages repository.

Configuring GitHub Pages

an image of a website page with the caption crazy max / ghaction - github - pages
an image of a website page with the caption crazy max / ghaction - github - pages

After pushing your HTML files, you need to configure GitHub Pages to serve your website. In your repository, create a new file named 'CNAME' (all caps) in the root directory. This file allows you to use a custom domain for your website.

Next, create a new file named 'index.html' in the root directory of your repository. This file is required for GitHub Pages to serve your website. You can leave it empty for now, as your existing HTML files will be served.

GitHub - GokuMohandas/Made-With-ML: Learn how to develop, deploy and iterate on production-grade ML applications.
GitHub - GokuMohandas/Made-With-ML: Learn how to develop, deploy and iterate on production-grade ML applications.
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 Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
Flutter for the Webβ€Šβ€”β€ŠDeploy to Github
Flutter for the Webβ€Šβ€”β€ŠDeploy to Github
How to Design Custom Github Demo Pages
How to Design Custom Github Demo Pages
Github Cheatsheet
Github Cheatsheet
AI agent workflow github open source deploy
AI agent workflow github open source deploy
Deploy vite app to GitHub pages for Free
Deploy vite app to GitHub pages for Free
HTML Document Structure
HTML Document Structure
How to Auto-Deploy Your Apps from GitHub in One Click?
How to Auto-Deploy Your Apps from GitHub in One Click?
login form html css
login form html css
The Beginner’s Shortcut to GitHub: Start Managing Your Code Like a Pro Today
The Beginner’s Shortcut to GitHub: Start Managing Your Code Like a Pro Today
an image with the text, code in your browser without any setup on it
an image with the text, code in your browser without any setup on it
GitHub - RamiKrispin/shinylive-r: A guide for deploying Shinylive R application into Github Pages
GitHub - RamiKrispin/shinylive-r: A guide for deploying Shinylive R application into Github Pages
How to Deploy a Website | Codecademy
How to Deploy a Website | Codecademy
π™ƒπ™π™ˆπ™‡ π™π™–π™œπ™¨ π™˜π™π™šπ™–π™© π™¨π™π™šπ™šπ™©
π™ƒπ™π™ˆπ™‡ π™π™–π™œπ™¨ π™˜π™π™šπ™–π™© π™¨π™π™šπ™šπ™©
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
Como fazer deploy de uma aplicaΓ§Γ£o do React com rotas no GitHub Pages
Como fazer deploy de uma aplicaΓ§Γ£o do React com rotas no GitHub Pages
Deploy Your Personal Web-Page With Hugo, Cloudflare and Github 100% For Free
Deploy Your Personal Web-Page With Hugo, Cloudflare and Github 100% For Free

Setting Up a Custom Domain

If you want to use a custom domain for your website, you'll need to update the 'CNAME' file with your domain name. For example, if your domain is 'www.johndoe.com', the 'CNAME' file should contain 'www.johndoe.com'.

After updating the 'CNAME' file, push your changes to the remote repository using 'git add CNAME', 'git commit -m "Add CNAME file"', and 'git push'.

Enabling GitHub Pages

To enable GitHub Pages, go to your repository settings on GitHub. Scroll down to the 'Pages' section and select the 'main' branch as the source. Click 'Save'.

It may take a few minutes for GitHub to serve your website. Once it's live, you can view your website at 'https://yourusername.github.io', or your custom domain if you've set one up.

Congratulations! You've successfully deployed your HTML website on GitHub Pages. Regularly updating your website with new content and features will help you build an impressive online portfolio. Happy coding!