Author: Miguel Teixeira
Tags: Resources, Hosting
Are you spending money on hosting? No more! You can use Github to host your startup website for free right now. Read this article to learn how.
So you created a website. Now it's time to roll it out. This is what you need to do before following these instructions:
- Have a domain,
- Have a website built,
- Register on Github.com,
- Install Git.
Github is an online service that enables developers to share and develop software. Github is based on Git, a widely used source code management system for software development. So it is critical that you understand some very basic Git scripts. In the course of this article we will teach you how to use Git and Github to get your website published and updated.
In Git and on Github there are a few concepts you need to understand to get your free hosting. First and most importantly, there are repositories which are pretty much projects. Then there are branches. Branches are like different versions or tastes of that project. So your project can branch off into different branches.
The DOM files are the files that the browser retrieves from the server where your site is hosted, in order to present a website. They are:
- html pages,
- CSS files,
- JS Files,
- all other elements present in your website.
A domain is basically the name of your website, like ideaninja.io or google.com. This name needs to be purchased and you need to hold the credentials to manage this domain, if you want to have a custom domain, instead of using the one that github will give you.
Go to Github and create a repository on Github for your website. Note that your branch now is called Master.
Create a new branched named gh-pages.
To clone the Github repository you have just created to your PC, create a new folder named Github and from there open a console by typing cmd, on windows, or terminal, if you are on mac. Then go to the folder you have just created and write the following command:
Git clone [repo url] --branch gh.pages .
Note: The repo url you can find on your repository page on Github where it says https. Copy it to the command and run it.
You will notice that some files have been downloaded.
Now copy the DOM files to the local repository you have just created. And in the command line write:
The terminal should ask you for your username and password from Github.
After that, if you go to your gh-pages branch in your Github repository you should see the files you have just pushed.
Test your website, through the following URL [username].github.io/[repository name]
Now, to get your site to respond in your custom domain, that you have purchased, add a File named CNAME (all Caps and no extension) and in that file write down your domain to your local repository. Repeat the same steps you did in step 4 (add, commit, push).
Now, go to your domain manager (website where you purchased the domain) and edit the Zone file or change it to this:
@ 10800 IN A 126.96.36.199
@ 10800 IN A 188.8.131.52
www 10800 IN CNAME @
Usually you can do this in DNS management, but it might be located in a different place, depending on the provider you have used.
Make sure that your domain is using the zone file you edited/created.
Note: it may take a few hours before the website is available. These new settings need to be propagated through the ISP, so don't worry if you cannot see your site right after you completed these 6 steps.