Until this point, this site initially started as a WordPress blog in 2012, and I switched to create the contents by using a static site generator, Jekyll, from 2014 to 2015.
In fact, all of the WordPress blog, Jekyll and Hugo sites were hosted on VPS having the basic CentOS + nginx (or Apache) environment. However, last week I eventually moved the site to GitHub Pages.
Basically, there were only 2 steps I needed to undergo:
- Create my
github.iopage and upload contents
- Set up custom HTTPS domain
(Nothing has changed from a user side.)
Surprisingly, moving a VPS-hosted site to GitHub Pages was really easy and comfortable than I expected for a long time. This new environment clearly motivates my weekly writing activity :)
Below I briefly writes down what I did to move this site.
Step 1: Hosting Static Pages Generated by Hugo on GitHub Pages
In order to host your Hugo-generated site on GitHub Pages, you first need to create own
github.io space as explained here: GitHub Pages Basics. Moreover, Hugo officially provides a tutorial page: Hosting on GitHub.
In my case, I have two repositories on GitHub, takuti/takuti.me and takuti/takuti.github.io; the former contains "source" contents which will be used to generate a site itself, and the latter has "destination" contents generated by Hugo.
In other words, once I hit:
Finally, pushing all contents under the
public directory to the GitHub
takuti.github.io repository automatically deploys and updates my page. Yay, I do not need to touch
rsync command anymore!
Step 2: Using Custom HTTPS Domain via Cloudflare
If you set up DNS and GitHub
github.io repository correctly, you can freely use custom domain on your GitHub Page. See using a custom domain with GitHub Pages for more information.
Here, I had a question before moving to GitHub Pages: Can we use custom "HTTPS" domains on GitHub Pages?
The answer is definitely YES thanks to Cloudflare. For more detail, Cloudflare officially introduces how to utilize secure HTTPS custom domain on GitHub Pages: Secure and fast GitHub Pages with CloudFlare.
Briefly, instead of using the original name servers provided by a domain registrar, we newly set up name servers on Cloudflare so that users' access to own domain goes though Cloudflare over SSL.
When I hosted this site on VPS, I installed free SSL certificate provided by Let's Encrypt. It was okay, but installing the certificate to an appropriate path, setting
httpd.conf) and updating the certificate might be complicated. Thus, using GitHub Pages + Cloudflare should be preferable in terms of manageability.
Support (Thank you!)
- Hello Netrify for Hosting a Static Site
- Deploying Static Site to GitHub Pages via Travis CI
- Migrate to Hugo from Jekyll: Another Solution for the MathJax+Markdown Issue
Author: Takuya Kitazawa
Takuya Kitazawa is a product developer, minimalistic traveler, ultralight hiker & runner, and craft beer enthusiast. Throughout my career, I have practically worked as a full-stack software engineer, OSS developer, technical evangelist, sales engineer, data scientist, machine learning engineer, and product manager. See my "now" page for more about what I am doing lately.
Opinions are my own and do not represent the views of organizations I am/was belonging to.