Yeah the answer is definitely yes, you can host your static website with the help of Github pages.
What is GitHub?
is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere with an open source version-control and collaboration platform for software developers and offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.
Github is delivered through a software as a service (SaaS) business model, was started back in 2008 and was founded on Git, an open-source code management system that was started by Linus Torvalds the same person who created Linux today to make software builds faster.
Why Use GitHub?
If you and your colleagues are working on the same website, and are updating the files by making changes, there will be no issues. However, if you and your colleague happen to make changes to the same page of the website, then there are chances of each other’s work being overwritten.
So here comes a version control software, which deals with the changes made to a file without allowing overwriting.
How to use GitHub?
To start using GitHub, you need no prior knowledge of coding at all. You need to download GitHub software to your computer. This offers you a visual interface through which you can manage your files locally. These files will be conveyed to the Web when you create an account in GitHub.
From then, you may start browsing the files of other GitHub users. You can also download those files, edit them and use for yourself. Even your files can be used likewise by other users. Git saves memory of all the changes made, so the original data is not lost.
How to Host Files in GitHub?
I am assuming that you already had have a github account and a little knowledge of git commands. It is easy to get started with github and hosting your website on github for free. Go and sign-up for a free account, if you don’t have one. Choose the free plan as that’s all we need for hosting our files.
Step1 : Create a Repository
- Click the “New Repository” button to create a new repository for hosting your files.
- Name your repository MyProject
- Write a short description.
- Select Initialize this repository with a README.
Step 2 : Create a Branch
- Go to your Repository MyProject
- Click the drop down at the top of the file list that says branch: master.
- Type a branch name, Readme-edit, into the new branch text box.
- Select the blue Create branch box
Step 3 : Make and Commit Changes
- Click the file.
- Click the Edit icon in the upper right corner of the file view to edit.
- In the editor, Write a commit message that describes your changes.
- Click Commit changes button.
Step 4: Open a Pull Request
- Click the Pull Request tab, then from the Pull Request page, Click the green New pull request button.
- Select the branch you made, Readme-edit, to compare with master(original). When you’re satisfied that these are the changes you want to submit, Click the big green Create Pull Request button.
- Give your pull request a title and write a brief description of your changes
Step 5 : Merge Your Pull Request
- Click the green Merge pull requestbutton to merge the changes into master.
- Click Confirm merge.
- Go ahead and delete the branch, since its changes have been incorporated, with the Delete branch button in the purple box.
In this repository you can host your static pages, you can manage this site by using that repository but keep in mind that Github allow only hosting for non MySQL database and static sites web page, if your website has server side part and also then you can still do it but intragated with others hosting environments like heroku, digitalocean and so on.
Note : if you want to host your site on your own custom domain just follow these steps:
- Add a CNAME file in your project and put it on the root of your project.
- Add the domain name in this like : www.yourdomain.com
- Commit it to the github and then you will see that your site has been published to your custom own domain at your registrars DNS settings on namecheap, namesilo, Gandi and etc.
- To change the DNS just go to your domain registrar and add an A record with the following value 220.127.116.11, 18.104.22.168.
- If this domain is a top level name, point the A record to 22.214.171.124. Otherwise, create a CNAME to username.github.io.
I hope that answer will help you to host your free site with github pages. Goodluck and all the best.