Deploy a website on GitHub for free in 5 simple steps

Rohan Gilbile
3 min readJan 29, 2023

--

As a developer, we always have the need of deploying our websites on the internet. There are several options for deploying a website for free. One popular choice is GitHub Pages, which allows for easy hosting of static websites. We will look into how we can deploy our website using GitHub.

GitHub Pages

We can deploy our static website on GitHub Pages by following the 5 steps mentioned below —

Step 1- Create a new repository on GitHub:

Go to GitHub and log in to your account. On your profile page, you will see a screen looking like this.

Github Profile Page

Click on the “New” button (in green) to create a new repository. Give your repository a proper name as the name will be in the URL that will be used to access your website. GitHub will ask you if you want to add a README file to the repository after you create it. Select “Initialize this repository with a README.” and click the “Create repository” button.

Step 2- Clone the repository to your local machine:

Using git, you can clone the repository to your local computer. Open a terminal and go to the folder where the website files should be kept. Run the command — “git clone https://github.com/username/repo-name.git" (replace “username” with your GitHub username and “repo-name” with your repository name). This will download the repository to your local machine.

Step3- Add the website files:

Copy all the files of your website (HTML, CSS, JavaScript, etc.) to the local repository folder. These are untracked files and are needed to be committed.

You can check the status of the file using the command — “git status

Terminal

Step4- Commit and push the changes to the GitHub repository:

Open a terminal and navigate to the local repository folder.

Run the command — “git add .” to stage all the files.

Then, run the command — “git commit -m ‘Initial commit’” to commit the changes.

Run the command — “git push origin main” to push the changes to the GitHub repository.

Step5- To build and publish the website, go to GitHub Pages:

GitHub Repository — Settings

Go to your repository page on GitHub. Click on Settings -> Pages. Under the build and deployment section select “Deploy from a branch” and select the appropriate branch which you want to deploy on GitHub Pages. Click on “Save” and you are done.

Your website should now be live and accessible at — https://<username>.github.io/<repositoryname>/ (Change the <username> to your actual GitHub username and <repositoryname> to name of your actual repo name). Alternatively, you can also go to the repository page on GitHub and click on github-pages in the Environments section to check out the deployed website.

Please let me know if there’s anything you need further help with. I’ll be happy to help you out!!

--

--