Hey guys in this Blog I’m going to tell you how you can host a website on Github. So for that what you need is you need to have –
- A valid Github account.
- The second thing is you need to have the code for your static website. So you may see there in the folder you may have the HTML code and you need to make sure that in the root directory of your code you have this index dot HTML. So this is important you need to have this index dot HTML in your root directory.
So let’s say I’m going to just see this index dot HTML in a browser and you can see it
looks like this. So I want to host a website on Github , let’s see how we can do it. So
- First of all you need to go to Github and then sign in with your Github credentials and once you are logged in to your Github account you need to create a new repository there.
So you can create a new repository by clicking this start a project button or you can click the green button there which says new repository. So I’m going to click on this new repository button.
- Now in here you need to give the repository name so because my website name will be in Turn Journey so that’s why I’m giving the name here Turn Journey. So in my case the repository name is Turn Journey. You can give any repository name whatever you like. Hope you know about Top 5 Best Free Web Hosting in 2021.
Description is optional so you can leave it as it is and make sure that public is selected here and then you just need to click on create repository. So now your repository is created and you will see here 3 ways of uploading your HTML code on this repository.
Now if you are familiar with gate then you can follow these Instructions or these instructions in order to upload your code on your repository and I have already made a post on how to use git and Github on your Windows operating system. We are going to do is we are going to follow all these commands and push our code onto Github.
- So first of all we will use this git in it command. Make sure that you have get installed on your system on which you are working and go to the directory where all of your HTML files are there right and then on windows operating system you can just right click and then click on git bash here.
So just click on get bash here which is going to open the command line and then you just need to give this command. Get in it and then press Enter which is going to initialize the gate on this repository and then I’m going to run and get status command to see the status.
- You can see all the files and folders are shown in red because they are not added to get so for adding these files and folders to get you can just right gite add and then dot. So just right gite add and dot and then press Enter which is going to add all these files in to git.
You can run get status once again to see if all these files are added or not. So you can see everything in green that means all the files are added. Now the next command is you just need to write git commit minus M and then you can give a small commit comment inside these double quotes.
- You can write first commit and then after that give a space and then give a dot here. Which means all the files and directories will be committed and once again when you run git status, you will see everything is committed. If you have a e-commerce site,have a look for Best Web Hosting For WordPress E-Commerce 2021.
So you just need to push your code into your repository. Now once again go to the Github and then you need to run this command which says git remote add origin and then URL to your repository.
- So I’m going to just copy this command and then paste it into the terminal and then press Enter which is going to add this remote region to your local git repository. Now in order to push your code into your repository what you need to do is you need to run this command.
Which is git push you origin/master and it’s going to ask your Github username and password. So I’m going to give this command and then after some time, it’s going to ask your username your username is the one which is shown there after Github.
- So you can see Github calm for knowledge is my username here. Okay so you just need to give the username here and then press enter and this will ask you your Github password. So just provide your Github password from here and then press ok. You can see all the files will be pushed to your Github repository.
Now so once this command is successful, we will once again go to our Github project here and we will click on the project which we have created. So just click on the project which you have created and you will see all the files will be uploaded to your Github project.
- So whatever files which are here you will be able to see all the files and directory in your Github repository. Now once you have transferred all the files on your Github repository, you can just go to the settings here. So just click on settings and then scroll down until it says Github pages.
So by default none is set here. So you just need to click on this drop down menu and then select master branch here. Then save the changes. So once you click on save you will be able to see this message which says your site is ready to be published at this URL.
- So you just need to right-click on this link and you can open this link in the new tab. Once you do this you can see your website is live on this URL which is your user name dot github dot forward slash whatever is your repository name.