How to host website on GitHub

Poojitha Ravuri
4 min readDec 22, 2020

--

Requirements:

  1. GitHub Account
  2. Git Bash on your system
  3. Your project to be hosted on GitHub

Follow the below steps for hosting your website on GitHub easily.

Step 1: Open github.com and sign in with your credentials.

Step 2: Create a new repository. For that click on the plus symbol and then click on new repository shown in below figure.

click on new repository

Step 3: Type the website name you want to give. In my case I have given as “sample”. Description is optional. And click on “public”, then click “create repository”.

Step 4: Now your repository has been created successfully. Now we need to follow the given commands given.

Step 5: Now, go to the directory where all your html files are present. As you have installed git bash, when you right click you will see an option “git bash here” . Click on that, a terminal will open.

Step 6: Now give the command “git init” and press enter, this will initializes git on this repository.

Step 7: Type the command “git status” to see the status of files. At present it will show in red color because the files are not yet added to git.

Step 8: Now for adding all files give the command “git add .”

Step 9: Now you can check the status of your files by typing “git status”. They will be in green as they are successfully added to git.

Step 10: The next command is → git commit -m “first commit” . You can write anything in quotes. Then press enter.

Step 11: If you run “git status” you will see that nothing to commit.

Step 12: Now go to github.com and copy the command to push our files.

Step 13: Now type the command “git branch -M main” then “git push -u origin main”. It will ask github username and password. Type your credentials.

Step 14: Now go to your repository and refresh the page. You will see your html pages in git.

Step 15: Go to settings and scroll down until you see github pages.

Step 16: In branch it will show as none. Click drop down and select main and save. You will see that “your site is published at “url” .

Step 17: When you click that link you will get error. Don’t Worry!!. Now go to your repository.

Step 18: Now create the master branch. Write master in the given text box and click on create.

Step 19: Go to setting and scroll down till you see github pages. Now change main to master in branch and save. Now click on the given link and now you will be able to find your site.

This is the sample page I created and hosted on github.

Step 20: Congratulations!! Finally we did it.

--

--

No responses yet