how i built this website in less than 1000 loc

Every system I have tried before this has failed to provide a seemless process from content to publishing. There is always some painful conversion step, workflow sacrifices, etc. So, why not make my own?

As of writing this blog post, the entire codebase for this project (minus the templates) sits at < 1000 LOC. It all exists in a single main.go file, because I haven't found a reason to split it up yet. This file does a few really important things:

  1. fetches all notes from a directory on my device
  2. converts markdown documents to HTML documents
  3. resolves wikilinks to website links
  4. parses and renders templates, inserting markdown content inside.
  5. builds indexes based on directory hierarchy, tags, etc.

As you can see, there's not a lot that goes into this website. It's essentially a dumb hugo reimplimentation.

tech stack

  • language: go
  • markdown parsing deps: goldmark and various extensions

Not much of a stack I guess. If this were a few years ago, I'd feel like I failed in building a complete system due to the lack of complexity. I don't think in such a way anymore. I'm proud of this simple system.

some quirks in the code

I wrote v1 of this website in 4 hours while listening to some pretty heavy music.

why not use an existing SSG?

There are a few reasons, but it mainly boils down to development overhead and configurability.

It may sound backwards, but rolling my own system is actually taking the easy route. Having to learn another person's tool, especially a professionally generic, one-size-fits-all type of tool can be an absolute burden when starting a project. I just need to copy and convert some files. I'm not afraid of writing code-in fact, I love it-so it seemed like a natural choice for me.

There are some really specific things about my workflow that would be less-than-trivial to implement in an existing tool. For example, wikilinks are not supported by hugo, nor does the prospect of them being supported in the future look promising. There are some third-party patches, but they don't seem active enough for me to trust that they will move steadily alongside hugo. Additionally, I have conditional inclusion parameters for notes, where I sometimes hoist notes from one directory to another. For example, I often reference a note that I have defined in my own personal note directory. I need that note pulled from my personal notes, copied, and placed in an appropriate path in my website. This means the SSG must have 2 contexts: the blog notes and the private (until needed) notes. Weird, right?

do I regret it?

Not yet. I like making things myself. The main upside to this approach is that any feature I want, I just write myself. There is no trying to adapt it to a foreign system.

Back to the Top