Why should you host CDN or a website in GitHub?
- GitHub is totally free if you would like to host your website/sub-domain publicly.
Yeah, It costs if you want to make private repositories.Now, GitHub provides unlimited private repositories.
- GitHub Support is awesome. They’re quick in giving response.
- It supports Jekyll. Which is static site generator. (Many bloggers host their blogs on GitHub.)
- We can also host One Page Website by just adding index.html and some stylesheets, images, etc.
- It works based on git which is a version control system so we can also see our previous version of the website, make new branches, people can submit pull requests, etc.
Note: There isn’t support for a language like php. Also GitHub doesn’t provide any analytics for your hosted site/CDN.
- First of all make a new repository in GitHub of your choice like if you want to host CDN of example.com then you should name repository cdn.example.com.
- Clone it in your desktop via GitHub app… or whatever application you used to clone repositories from GitHub.
- Then delete the branch master if it’s there (It’s there if you checked Initialize this repository with a README and/or added .gitignore and/or added license file), and then just make a new branch called gh-pages.
- Then add your content there like index.html, style.css, images, etc.
- Then add CNAME which is used to set up a sub-domain with Github, in CNAME write your sub-domain name like cdn.example.com.
- Commit and Push it to GitHub.
- Go to your Domain Control Panel (where you’ve purchased your domain) and go to the domain’s CNAME Records.
- Add a CNAME record with hostname like here cdn.example.com and in the value field type username.github.io. (username will be your username of GitHub/organization username of GitHub.)
- Then click Submit/Add Record.
Now wait for some minutes (approximately 10 minutes) and your sub-domain will be hosted in GitHub. If you face any issues while configuring this, you can email to GitHub Support or you can fill this form.
Thank you very much for your precious time. If you enjoyed reading this article, kindly share this with your friends.