Host HTML CSS JS Website on GitHub: Step-by-Step Guide

Ann Jul 09, 2026

Hosting a website built with HTML, CSS, and JavaScript on GitHub is a straightforward and cost-effective solution. GitHub Pages, a static site hosting service, allows you to publish your website directly from a GitHub repository. Here's a step-by-step guide to help you host your website on GitHub.

a person pointing at a computer screen with the words build and host your website free on github
a person pointing at a computer screen with the words build and host your website free on github

Before we begin, ensure you have the following: a GitHub account, your website's HTML, CSS, and JavaScript files, and a basic understanding of Git and GitHub.

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

Setting Up Your GitHub Repository

First, create a new repository on GitHub. Name it using the following format: yourusername.github.io, replacing yourusername with your GitHub username.

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

Once the repository is created, you'll see a green button labeled "Create a new file." Click on it to create an index.html file, and add your website's HTML code to it. Click "Commit new file" to save your changes.

Adding CSS and JavaScript Files

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

Next, add your CSS and JavaScript files to the repository. Click on the "+" icon in the repository's file list to create new files for your stylesheet (styles.css) and script (script.js). Add your CSS and JavaScript code to these respective files and commit the changes.

To link your CSS and JavaScript files to your HTML file, update the index.html file with the appropriate <link> and <script> tags. For example:

<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>

Configuring GitHub Pages

Html, Css Login Tamplates
Html, Css Login Tamplates

To enable GitHub Pages for your repository, create a new file named CNAME (all caps) in the root of your repository. This file should contain the domain name you want to use for your website (e.g., yourusername.github.io).

Next, create a new file named .gitignore (with a leading dot) in the root of your repository. Add the following line to this file to ignore the CNAME file from Git:

CNAME

Deploying Your Website

html and css login form
html and css login form

Now that your repository is set up, it's time to deploy your website. GitHub Pages will automatically deploy your website whenever you push changes to the main branch of your repository.

To deploy your website, push your changes to the main branch using Git. If you haven't already, initialize a local Git repository for your project and connect it to your GitHub repository. Then, commit your changes and push them to the main branch:

How to Center Anything in CSS (5 Ways)
How to Center Anything in CSS (5 Ways)
HTML, CSS, and JS: A Beginner’s Guide to Web Development
HTML, CSS, and JS: A Beginner’s Guide to Web Development
the top 10 projects for beginners to practice html and css skills with text
the top 10 projects for beginners to practice html and css skills with text
CSS Notes for Beginners (Easy + Quick Guide) 🎨
CSS Notes for Beginners (Easy + Quick Guide) 🎨
#CSS Animations Tips and Tricks
#CSS Animations Tips and Tricks
Website cupcake design using html and css.mp4
Website cupcake design using html and css.mp4
Master Css Using These Websites..
Master Css Using These Websites..
an image of a web page with the text'voyage slider '
an image of a web page with the text'voyage slider '
The Best HTML and CSS Courses for Beginners - Mikke Goes
The Best HTML and CSS Courses for Beginners - Mikke Goes
Coding a Stylish Blog Design Layout in HTML & CSS
Coding a Stylish Blog Design Layout in HTML & CSS
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
How to Link CSS in HTML | Web Development Tutorial 🔥
How to Link CSS in HTML | Web Development Tutorial 🔥
🎨 3 Ways to Add CSS | Inline, Internal & External CSS Explained
🎨 3 Ways to Add CSS | Inline, Internal & External CSS Explained
the different types of html tags are shown in this screenshote screen graber
the different types of html tags are shown in this screenshote screen graber
Css,html
Css,html
Upload Image using JS 🤳| HTML CSS JavaScript
Upload Image using JS 🤳| HTML CSS JavaScript
How To Create Text Slider With Pure HTML CSS
How To Create Text Slider With Pure HTML CSS
the cover of how to set a background image in css, including text and numbers
the cover of how to set a background image in css, including text and numbers
CSS button animation
CSS button animation
an image with the text how to place text over image in html css
an image with the text how to place text over image in html css

git add .
git commit -m "Deploy website"
git push origin main

Accessing Your Live Website

After pushing your changes, GitHub Pages will automatically deploy your website. You can access it by navigating to https://yourusername.github.io in your web browser. Replace yourusername with your GitHub username.

That's it! Your HTML, CSS, and JavaScript website is now live on GitHub. You can update your website by pushing changes to the main branch of your repository.

As your website grows, you might want to consider organizing your files into folders. You can create new folders in your repository by clicking the "+" icon and selecting "Create new folder." Just remember to update your file paths in your HTML, CSS, and JavaScript files accordingly.

Happy coding, and enjoy the ease of hosting your website on GitHub!