Home
| Colors: |
February 2026

Default Pages for a Static Site Generator

More work on bitty's1 documentation is under way. I'm using files and directories for all the data instead of putting it into a database. Pages are assembled by including files inside each other.

I use a directory structure like this:

data-receive
  index.html
  tests 
    basic-check
      name.html
      notes.html
      sample.js
      trigger.js
    bounce-check
      name.html
      notes.html
      sample.js
      trigger.js

The index.html file is what gets served. Its content is built by looping over the tests directory and combining the files from the directory for each test.

Each Like the Other

Every test directory has the same set of files with the following features:

  1. The name.html and script.js are different for each test.
  2. The trigger.js file is the same for 90% of the tests.
  3. The notes.html file is usually empty.

Unsurprisingly, I wrote a script that watches for new test directories and stubs in an initial set of files.

The thing is, the trigger.js file has evolved over time. So, I needed a way to update it. The trick being to avoid overwriting any of the versions of the file I customized.

Scoring the Default

The solution I'm using is all about and underscore. It breaks down like this:

  1. My script generates the default version of trigger.js with a leading underscore on the file name:

    _trigger.js
  2. I rename the file to remove the underscore if I need to customized the test.

    trigger.js
  3. I re-run my file generation script when the trigger format changes.

    • If the trigger.js file exists, the script doesn't do anything for that test.
    • If the trigger.js file doesn't exist, the script creates or updates the _trigger.js file.
  4. When the site builds, the trigger.js file gets included if it exists. Otherwise, the fallback _trigger.js is used.

The Name is the Game

Removing the other files from the directory tree for a moment we get this:

data-receive
  index.html
    tests 
      basic-check
        _trigger.js
      multi-check
        trigger.js
      rebound-check
        trigger.js
      static-check
        _trigger.js

Using the name of the file as a toggle to determine what should happen in both stubbing and output is nice. Removing a single character takes care of everything for me. It's also an instance read for which files are the default and which have been customized.

I'm all about reducing the friction it takes to make thing. This is a nice one that lets me focus on content rather than on how it's stored.

-a

end of line

Endnotes

The site is built with a custom static site generator built around MiniJinja (rust's version of Jinja). It's fantastic.

This is a cut down version of the directory structure to make the example clearer. The actual one has more levels and everything starts with the _ named stub file.

Footnotes

Version 8 is underway. I've got a good feeling about this one.