How to Publish Your Website on GitHub

Ann Jul 09, 2026

Publishing a website on GitHub is an excellent way to showcase your projects, collaborate with others, and even host static websites for free. GitHub Pages, a static site hosting service, makes this process straightforward. Let's dive into the step-by-step guide to publish your website on GitHub.

Host Websites Free with GitHub Pages 🚀💻
Host Websites Free with GitHub Pages 🚀💻

Before we start, ensure you have a GitHub account and have installed Git on your local machine. If you haven't, you can create an account at github.com and download Git from git-scm.com.

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

Your first step is to create a repository (or repo) on GitHub to host your website.

How to have a Free Website on GitHub | موقع الإلكتروني مجاني
How to have a Free Website on GitHub | موقع الإلكتروني مجاني

1. Log in to your GitHub account and click the '+' icon in the top-right corner, then select 'New repository'.

Naming Your Repository

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

Name your repository in the format username.github.io, replacing 'username' with your GitHub username. This is crucial for GitHub Pages to recognize your repository as a user or project page.

For example, if your username is 'johndoe', your repository should be named 'johndoe.github.io'.

Initializing Your Local Repository

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

Next, initialize a local Git repository on your computer where you'll create and store your website files.

Open your terminal or command prompt, navigate to the directory where you want to create your project, and run the following commands:

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

Replace 'yourusername' with your actual GitHub username.

How To Host A Website On Aws, Github Beginner Guide, Website Hosting Options Explained, Substack Homepage Screenshot, Debian Web Hosting Guide, How To Start Using Github, How To Create A Github Repository, Github Repository Setup Guide, Cybersecurity Future Predictions
How To Host A Website On Aws, Github Beginner Guide, Website Hosting Options Explained, Substack Homepage Screenshot, Debian Web Hosting Guide, How To Start Using Github, How To Create A Github Repository, Github Repository Setup Guide, Cybersecurity Future Predictions

Building Your Website

Now that your local and remote repositories are set up, it's time to create your website.

Beginner’s Guide to Getting Started with GitHub in 2025 – Easy Step-by-Step Tutorial
Beginner’s Guide to Getting Started with GitHub in 2025 – Easy Step-by-Step Tutorial
a laptop computer sitting on top of a wooden desk next to a cup of coffee
a laptop computer sitting on top of a wooden desk next to a cup of coffee
How To Create A GitHub Repository In This Easy Step-by-step Guide For Beginners.
How To Create A GitHub Repository In This Easy Step-by-step Guide For Beginners.
Open Online VS CODE from GitHub
Open Online VS CODE from GitHub
How to Build a GitHub Portfolio That Gets Noticed
How to Build a GitHub Portfolio That Gets Noticed
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
Cómo subir tu Web GRATIS en github #aprendecontiktok #aprendeentiktok #techtok #profesentiktok #tech
Cómo subir tu Web GRATIS en github #aprendecontiktok #aprendeentiktok #techtok #profesentiktok #tech
How to Get Your Site Online for Free With Github Pages - Learn to Code With Me
How to Get Your Site Online for Free With Github Pages - Learn to Code With Me
How to upload a project to GitHub
How to upload a project to GitHub
How to Make a Website From Scratch With Domain and Hosting
How to Make a Website From Scratch With Domain and Hosting
#git #github #versioncontrol #interviewpreparation #softwaredevelopment #devops #learningjourney #sdet #qatesting | Satya Tharun Manikanta Nalle
#git #github #versioncontrol #interviewpreparation #softwaredevelopment #devops #learningjourney #sdet #qatesting | Satya Tharun Manikanta Nalle
Build Your First Website: 10-Step Beginner Roadmap (No Confusion)
Build Your First Website: 10-Step Beginner Roadmap (No Confusion)
How to use GitHub | What is GitHub | Git and GitHub Tutorial | DevOps Training | Edureka
How to use GitHub | What is GitHub | Git and GitHub Tutorial | DevOps Training | Edureka
How to Build a Professional Website in Minutes | No Coding Needed
How to Build a Professional Website in Minutes | No Coding Needed
How to Create a Github Page for Your Project
How to Create a Github Page for Your Project
How To Use GitHub | GitHub Tutorial For Beginners | Edureka
How To Use GitHub | GitHub Tutorial For Beginners | Edureka
Top GitHub Projects for Resume (Python)
Top GitHub Projects for Resume (Python)
How to Make a Website on Your Own (Step-by-Step Guide)
How to Make a Website on Your Own (Step-by-Step Guide)
What Recruiters Look For in a GitHub Profile
What Recruiters Look For in a GitHub Profile
an image of a web page with the title 6 / public - apis a collective list of free and open apis for use in software and web development, categ
an image of a web page with the title 6 / public - apis a collective list of free and open apis for use in software and web development, categ

You can use any text editor or IDE to create your website files. For simplicity, let's use plain HTML, CSS, and JavaScript. Create an 'index.html' file and add your website content. You can also create additional files like 'style.css' for styling and 'script.js' for functionality.

Commit Your Changes

Once you've created your website files, commit them to your local Git repository.

Use the following commands to add, commit, and push your changes to the remote repository:

git add .
git commit -m "Initial commit"
git push -u origin main

Enabling GitHub Pages

Now that your website files are in the remote repository, it's time to enable GitHub Pages.

1. Go to your repository on GitHub.

2. Click on the 'Settings' tab at the top of the repository.

3. Scroll down to the 'GitHub Pages' section.

4. Under 'Source', select 'main' (or the branch you want to use for your GitHub Pages).

5. Click 'Save'.

Viewing Your Live Website

After a few moments, your website should be live at https://yourusername.github.io. Replace 'yourusername' with your actual GitHub username.

Congratulations! You've successfully published your website on GitHub.

Customizing Your Domain

If you want to use a custom domain for your website, you can do so by following GitHub's guide on configuring a custom domain.

Remember to keep your website updated by pushing new changes to the GitHub repository. You can also collaborate with others by adding them as contributors to your repository.

Embarking on this journey, you've not only published your website but also learned valuable version control and collaboration skills using Git and GitHub. Happy coding, and here's to many more websites to come!