Hosting a website enables many web users to access our web pages at the same time. If you want to run a website you need web hosting because unless you’ve got unlimited funds you would not be able to afford the web servers. GitHub has a lot to offer, it provides free hosting to your static website. To host the website via GitHub you’ll require a valid git account, the git software and all the codes and files of your static website.
In this article we’re going to learn how to host a static website on GitHub, let’s get started:
Step 1: Create / Sign into your GitHub account.
Step 2: Click on create a New Repository, give it a name and make sure to make it public.
Step 3: Go to the directory where all the HTML files are present, right-click and select Git bash here which is going to open the command line.
Step 4: Give the command “git init” which will initialize a git repository.
Step 5: Give the command “git add .” which will add all the files into the repository.
Step 6: Now check the status of the repository by giving the command “git status“, if all the files are in green means the files are successfully stored in the repository.
Step 7: Give the command “git commit -m “my first commit” .” by which you give your first commit in git.
Step 8: Give the command “git remote add origin https://github.com/vaishnavigupta447/geek-sSite.git” which would be the url given in your github id. This will add the remote origin to your local git repository.
Step 9: To push your code in repository give the command “git push -u origin master“, which is going to ask your username and password.
Step 10: Go to the GitHub page, click on your project and you can see all the files are pushed in the repository. Go to the setting and find GitHub Pages, in the source section from the drop-down menu select master branch save the changes.And your Site is successfully published, copy the url and open it in the new tab.
And yes!! your page is published at free of cost. Share the link of your page and it can be accessed by numbers of web users at the same time.