Az

My Site On Gopher

Having played around a bit with Gopher lately I decided to take the next step and try and create something more meaningful then test directories and dummy text files. My ultimate goal was to have this personal blog available via Gopher as well and I’m pretty confident that I achieved it. You can visit gopher://gopher.judges119.me and you’ll be able to browse my personal, dev, and ops blogs via the Gopher protocol. I also uploaded the code for it to GitHub if you wanted to do the same.

Hugo Gopher

The tool I made is incredibly opinionated and limited, however I might try and build on it a bit to improve functionality and usability in the near future. In essence it uses Node.js to read all the Markdown blog post files from a Hugo project (a lightning fast static site generator), reads the frontmatter (metadata stored at the top of a file) then outputs the remaining text to files in date-ordered directories. It also generates Gopher directory files to ease in navigating the site.

The entire tool was written in plain Node.js v10+ with no third party packages, just the default APIs (even then, only the fs and path ones) which I’m pretty happy with. It’s relatively simple in operation and I can see a few areas for improvement, but I’m pretty happy that I used a relatively simple chaining of functional, event-driven code that hopefully makes sense when read.

Future Improvements

  • Work with YAML/TOML frontmatter, not just JSON.
  • User starts the script and supplies the correct directory, rather than editing the index.js files
  • Hosted on npm and usable as a globally installed command
  • Output to user-specified directory
  • Tested with other Gopher daemons aside from just PyGopherd

Other Attempts

I also spent ages reading the Hugo source code which is written in Go, a language I am not familiar with. I was not able to work out how I could easily bolt in the ability to output as a Gopher site, but I’m not too perturbed, that would have been a pretty heavy undertaking given how complex the Hugo code is in order for it to be so configurable and lightning fast.