How this website is built - Nix and ox-hugo

A few months ago I announced that I’m now using ox-hugo but didn’t go through the whole setup. Now the time has come to show you how everything works here. It basically works around three main tools (that I assume you already know about):

I use GNU Emacs to edit a single Org file placed at content-org/ that contains all the contents of this website. There’s also a file called .dir-locals.el that I use to activate the function org-hugo-auto-export-mode when I open an Org file inside the website’s directory.

  . ((org-mode . ((eval . (org-hugo-auto-export-mode)))))))

org-hugo-auto-export-mode is responsible to automatically export the article I’m editing to the content directory as a Markdown file on each save I do, allowing me to use Hugo’s auto-reload feature.

This was the trickiest part of the whole process. I ended up creating a file called export.el with the function I found here to export all my files at once on CI. If you don’t use Nix, all you need is a GNU Emacs with ox-hugo installed and then run this:

emacs $(pwd) --batch -load export.el

Now, if you’re a Nix person, you can easily create a derivation to build everything with a custom GNU Emacs.

  customEmacs = (emacsPackagesFor emacs-nox).emacsWithPackages
    (epkgs: with epkgs.melpaPackages; [
    ++ (with epkgs.elpaPackages; [
stdenv.mkDerivation {
  name = "glorifiedgluercom";
  src = lib.cleanSource ./.;

  buildInputs = [

  configurePhase = ''
    emacs $(pwd) --batch -load export.el

  buildPhase = ''

  installPhase = ''
    mkdir -p $out
    cp -r public/* $out

Links to this article

Articles from blogs I follow around the net

Trimming a Fake Object

A refactoring example. When I introduce the Fake Object testing pattern to people, a common concern is the maintenance burden of it. The point of the pattern is that you write some 'working' code only for test purposes. …

via ploeh blog November 20, 2023

Building a digital vigil for those we've lost

This post is hard to write in a lot of ways. It's more personal than most I've written. This is presumptively a tech blog, and this piece is about so much more than technology. But it's important. Making things, software or otherwise, is ultimatel…

via blog November 19, 2023

#122 Experimenting and Learning

Update on what happened across the GNOME project in the week from November 10 to November 17. GNOME Circle Apps and Libraries Workbench A sandbox to learn and prototype with GNOME technologies. Sonny says Workbench is a code playground and Library to learn, e…

via This Week in GNOME November 17, 2023

Generated by openring