Time to complete: 1 hour typing, 12 hours waiting. See the source.
- Google Domains
- Hugo - blog engine
- GitLab - CI, hosting, Let’s Encrypt
Buy your domain from Google Domains and create a DNS A record which points to GitLab’s IP address. Create a new project in GitLab using the Hugo template and call it yourusername.gitlab.io.
In the Pages configuration for your GitLab project add a new domain and select Let’s Encrypt. You’ll be instructed to add a special TXT DNS record to prove you own the domain so get back to Google Domains and add that.
In the CI section on GitLab trigger a build in Pipelines to create and deploy your static website to https://yourusername.gitlab.io.
Everything is in place, you just need to leave it for a few hours for the DNS records to propagate. But do be aware that your website might be inaccessible during this time.
I migrated my Ghost blog by exporting it as a JSON file and then using
jekyll_ghost_importer to extract the posts. However, this doesn’t export the images – which wasn’t such a big deal for me – but it’s worth bearing in mind. This also creates posts with the Jekyll date prefix but you batch rename those on the command line.
Committing to GitLab
As Hugo is a static blog engine you might assume that you need to commit your generated site. But you’re wrong. You simply commit the source (markdown) then the live site is generated in the “public” directory and published by GitLab. In fact “/public” is explicitly ignored in
Creating new posts
On Linux you can use the Hugo command line tool to generate a new post.
hugo new post/yeah.md
But once you get used to it you can just create new markdown files in
content/post, even using only the GitLab IDE if you like. Just add the following front matter at the top of the file, you can use a simplified
YYYY-MM-DD date format too if you don’t care about the precise time.
--- title: Hugo Blog subtitle: Create a blog like this date: 2019-09-09 draft: false - tag1 - tag2 ---
If you’d like to access your blog from another domain you can add it via your Pages settings. You can also generate a Let’s Encrypt certificate.
Site last built: Fri Feb 28 13:51:11 UTC 2020
Hugo Static Site Generator v0.56.3-F637A1EA linux/amd64 BuildDate: 2019-07-31T12:51:09Z
Linux runner-fa6cab46-project-16511878-concurrent-0 4.19.78-coreos #1 SMP Mon Oct 14 22:56:39 -00 2019 x86_64 Linux