Set up Github account
Go to Github and create a new account. For those unfamiliar, github is a platform where anyone can store their projects and code. Kinda like google drive, but for developers.
Download Git
Download Git. Git is an open source and free version control system.
This means it keeps track of changes made to your files and lets you review and revert to older versions.
Go and "git" it if you have not already done so.
Create a new repository
Create new repository in github. Add repository name in the field below and select the green button create repository.
In the new page that opens up, choose option `...or create new repository on the command line` and copy that code.
Load files to github (via git)
Next, go to folder where your website is stored on your local computer. Right click on this folder and select gitbash here. This will open up a new command line, with the git program you installed.
Copy and paste that code into the command line. Using shift + insert or right click paste.
If that does not work try the following command line:
git push https://github.com/<YOUR USERNAME>/<YOUR REPO NAME>.git
When you click on your repo name, you should see all your website files there! Congrats, the hard part is done.
Show website on github
In the command line that is still open in git, type the following:
git checkout gh-pages
This will switch the branch you are working on from the main branch to the gh-pages branch. The gh-pages branch allows you to show your website, not just your files to others.
Finally in the command line we will do one more push to github, but this time to the gh-pages branch.
git push https://github.com/<YOUR USERNAME>/<YOUR REPO NAME>.git
In github you should now be able to see two branches. One called master and one called gh-pages.
You are now also able to show the world your site. Try this out by typing in the following url:
https://<YOUR USERNAME>.github.io/<YOUR REPO NAME>/
Using a custom domain name
For obvious reasons you might want to have your own domain name. In this example, Namecheap will be used, but this should be similar for other domain service providers.
Afer buying your domain name, change the DNS configurations. In namecheap, under the list of domains, click on manage and then advanced DNS to change the value of the CNAME record. If it is a new domain, the value will be something like parked domain, or parkingpage. Change this value to your github username:
<YOUR USERNAME>.github.io
Next, change the TTL to 1 minute or so and make sure the value of the URL Redirect Record is your domain name.
Finally, go to your repo settings in github, or visit this url
url https://github/<Your User Name>/<Your repo name>/settings
Under GitHub pages, right before the danger zone section, change your custom domain from blank to your purchased domain name.
Wait and Check
Wait for a couple minutes and then type your domain name into the url. Did your site show up? If so congrats! You are now hosting a site for free with github.
Hope you enjoyed this article. For questions, commments and feedback please drop me a line at: admin@dash-intel.com
Photo credit Three-shots on Pixabay.