luo.box

Building a Static Blog is Hard

Published:

Building a static blog is hard

I’ve finally decided to start an new blogs (there were two perviously but didn’t last). Not only was my procrastination and perfectionism preventing me from doing it but also because building a correct and simple static blog is hard and complicated.

I do have higher standards for anything technology related, and when I want to do something, I want to do it right.

Some goals: to break it down.

There is a whole huge rabbit holes regarding to indieweb, polygon xhtml, gemini, tar compatibility, and more strict standards that I’m not ready to jump in right now. Maybe for the future.

these immediately yield some results:

Toolchains I need:

It’s in 2024 and there are hundreds of all kinds SSG and I’m amazed by the fact that no one ticks all these boxes. For now I’m settled with blades, a rust based SSG that uses mustache as its templating solution. It’s fast, simple to use, generates atom, rss, and sitemap, has rudimentory support for mathml and syntax highlighting. Though it doesn’t not support github footnote style, table of content. And it’s currently not actively maintained (the author left github). We’ll see how lone it goes, and when it fails me I might start a new SSG on my own.

Current workflow

I’m using Nix to save my life.

Here is the flake.nix of this website:

{
  description = "My personal website";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = nixpkgs.legacyPackages.${system};
      in {
        packages.website = pkgs.stdenv.mkDerivation {
          name = "blog";
          src = self;
          buildPhase = "${pkgs.hugo}/bin/hugo";
          installPhase = "cp -r public $out";
        };

        defaultPackage = self.packages.${system}.website;
        devShells.default = pkgs.mkShell { packages = [ pkgs.hugo ]; };
      });
}

I use sourcehut to host my website. When I pushed to the git repository, it will be deployed automatically using the sourcehut build service. In the build, nix build uses flake.nix to create exactly same environment as in development:

image: nixos/latest
oauth: pages.sr.ht/PAGES:RW
packages:
- nixos.hut
environment:
  NIX_CONFIG: experimental-features = nix-command flakes
  site: yejun.dev
tasks:
- package: |
    cd $site
    nix build
    tar -C result -cvz . > ../site.tar.gz    
- upload: |
    hut pages publish -d $site site.tar.gz   

Some results

Todos

Some resources and inspiration

The clubs:

#website