Moving to Hugo

Post at — Nov 23, 2024
#Blogging #Development

Recently as I was trying to get my blog page going, after a good 4-month hiatus, I ran into a massive problem.

In attempting to run my blog site locally using Jekyll, problems immediately arose.

1
2
3
4
5
# Entering my dev shell
nix develop

# Hosting my site on a local http server
jekyll serve

My attempts left me with nothing but a torrent of errors, of which of course, I had no intention to deal with. I honestly never use Ruby, so I saw no reason to uproot my configuration just to get it running again.

Then a glimmer of hope shone through the clouds of FOSS.

Introducing Hugo

Hugo, being a service I had only heard of in passing, was a very promising alternative to Jekyll. One that proves to be really easy to use and work with on NixOS.

Set up

The process was really simple.

1
hugo new site "Site name"

There was some initial setup I had to do, getting my development environment going:

1
nix flake init

Then creating a basic flake.nix file, creating a nice dev shell.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  description = "My personal blog";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

    # Flake-utils is not necessary, but nice to have for me ^.^
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };
      in
      {
        devShells.default = pkgs.mkShell {
          buildInputs = with pkgs; [
            hugo
          ];
        };
      }
    );
}

From there the rest is pretty simple, launch the blog whenever you with to preview or create content:

1
hugo server -D --buildDrafts

Finding a useful host was a bit of a problem, but Vercel has been a decent hosting service so far.

Moving forward

I am really excited to get this blog going again. I hope to put in quite a bit more time and research into my new posts. Ikuzo!