Moving to Hugo

Nov 23, 2024    m. Mar 23, 2025    #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.

# 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.

hugo new site "Site name"

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

nix flake init

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

{
  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:

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!