how to deploy a website on github

Mastering GitHub: Easy Steps to Deploy Your Website

By Brian Thomas
AD

Deploying a website on GitHub Page is a straightforward process that allows you to share your website with the world in just a few clicks. We'll walk you through this simple yet powerful method, ensuring your website is live and accessible in no time.

Before we start, ensure you have a GitHub account, and your local website is a standard HTML, CSS, and JavaScript project. If you haven't initialized a Git repository for your project, do so with `git init` in your terminal. Now, let's dive into deploying your website on GitHub Pages.

Setting Up Your GitHub Repository

Your GitHub repository serves as the remote storage for your website. Start by creating a new repository:

AD
How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages
How to Get Started With GitHub in 2026 and Build Real Projects Fast
How to Get Started With GitHub in 2026 and Build Real Projects Fast
Hosting Your Portfolio Website for Free Using GitHub Pages
Hosting Your Portfolio Website for Free Using GitHub Pages

1. Log in to your GitHub account. Click the '+' icon in the upper right corner and select 'New repository'.

Namimg Your Repository

Name your repository in the format `username.github.io`, where `username` is your GitHub username. This is necessary for GitHub Pages to recognize it as a hosting repository.

Follow the Steps Outlined in This Guide to Set Up Your GitHub Repository As Web Page,
Follow the Steps Outlined in This Guide to Set Up Your GitHub Repository As Web Page,
GITHUB PROJECTS THAT CAN GET YOU HIRED
GITHUB PROJECTS THAT CAN GET YOU HIRED

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

Cloning Your Repository Locally

Clone your newly created repository to your local machine:

AD
  1. Open your terminal or command prompt.
  2. Type `git clone https://github.com/yourusername/yourusername.github.io.git` and press Enter. Replace `yourusername` with your actual GitHub username.

Preparing Your Local Website for Deployment

Your local HTML, CSS, and JavaScript files will be hosted from the 'main' branch of your repository. Ensure your project structure is organized accordingly:

1. Place all your website files (HTML, CSS, JS, etc.) inside the cloned repository folder.

2. Let's say you have an `index.html` file. Its location should now be `{username}.github.io/index.html` in your filesystem.

AD

Commit Your Changes

Commit your changes with a descriptive message. This ensures your website's current state is saved on GitHub:

  1. Run `git status` to check if your changes are tracked.
  2. Add all changes with `git add .` (note the dot) and commit with `git commit -m "Initial commit of my website"`.

Pushing Changes to GitHub

Push your local changes to your GitHub repository:

  1. Use `git branch -M main` to rename the branch (if necessary) and `git remote add origin https://github.com/yourusername/yourusername.github.io.git`.
  2. Finally, push your changes with `git push -u origin main`.

Enabling GitHub Pages

GitHub Pages uses a specific file (`.github.io`) to recognize your repository as a website hosting one. Let's set that up:

AD

1. Go to your repository on GitHub.com and click 'Settings'.

Activating GitHub Pages

Scroll down to the 'GitHub Pages' section and select 'main' (or 'master') as the Source. Click 'Save'.

After a moment, your website should be live at the URL, `https://yourusername.github.io`. If you haven't already, go ahead and click that link to view your deployed website!

From here, you can continue refining your website, adding new features, or even switching to a custom domain. GitHub makes managing your website simple and straightforward. Happy coding and sharing your creations with the world!

AD