Host your website with GitHub

Posted: 25 August 2013, Category: Coding

Did you know that GitHub is capable to host a simple website for free, well I didn't but I found it interesting enough to write a blog post about it.

That's right, if you have simple website containing HTML, CSS and JavaSript, GitHub will happily host your website for free.

GitHub also offers possibility to add domain name or sub-domain name if you have domain registered.

For those who have little or no knowledge of coding and need simple website to show their graphic artwork for example I recommend to check out http://pages.github.com/ and read documentation.

Web Designers and Web Developers with coding and basic Git skills can create own depository which is needed to publish website through GitHub.

As you probably guessed from blog title this post is about setting up free web hosting and custom sub-domain for free thank to GitHub.

Creating GitHub remote repository and gh-pages

  1. Create GitHub remote repository
  2. Push files from local git repository to master branch in remote repository created
  3. Create branch gh-pages
  4. git branch gh-pages
  5. To see branches in repository
  6. git branch
  7. Push files from master branch to gh-pages branch
  8. git push origin gh-pages
  9. In couple minutes is possible to see your website hosted on free GitHub account by typing yourusername.github.io/nameofrepository

Well done, now is the time to add custom domain name or in my case sub-domain name

  1. Create sub-domain in domain manager such as subdomain.josefzacek.com
  2. Create CNAME record and point it to your GitHub account such as josefzacek.github.io
  3. Create file called CNAME on your local computer
  4. Type name of sub-domain created in CNAME file
  5. Add and commit changes to local Git repository and push them to remote GitHub repository
  6. Push files from remote GitHub master branch to remote gh-pages branch
  7. git push origin gh-pages
  8. It again takes a couple of minutes to propagate but eventually your website will be available at subdomain.josefzacek.com

I hope you enjoyed GitHub post and if you have any questions or suggestions please do not hesitate and contact me.

Back to Blog page

Blog categories

Twitter feed

(11 days ago)
Ruby on Rails 5.2.0 Changes and New Features https://t.co/Bqdo081cvS via @driftingruby


(29 days ago)
Popular CSS Button Hover Effects Explained https://t.co/7rvOZtDRtK via @ddrivegeorge


(about 1 month ago)
Tracking Errors with Sentry https://t.co/21W2ml22jD via @driftingruby


(about 1 month ago)
Chrome to force .dev domains to HTTPS via preloaded HSTS https://t.co/mUz84bAVV1 via @mattiasgeniar


Top of page