Compiling all .skb files at once

September 5th, 2026

a

a

First off, I apologize if this is being read from a phone. I can't find a way to make the text wrap to work, so you'll have to scroll in the code segments.

This site being entirely written in Skribilo, this means that every time I make a change anywhere I need to recompile the file I updated for the changes to be visible in the HTML. This can definitely become tedious, and hard to keep track of (if you have a lot of files with changes), real quick. This is specially true when you realize the command to compile is

skribilo --target=html <skb-file-name>.skb -o <html-file-name>.html

To solve this issue I wrote the following simple program, broken into parts:

Terminal command and args

In order to run the program, I need 2 optional arguments. Could I have done this without argparse? Yes, of course, but I wanted to add the --help flag (as if anyone else is using this), so it was needed.

I decided to give it two optional arguments:

  • -path: Relative path to the file we wish to compile. In case we want to only compile a specific file, as opposed to all of them at once.
  • -out: Name of the output file. In case the user wishes to give their compiled HTML file a different name from the Skribilo one.

Compiling a single file

If the user provides the -path then we know we'll compile a specific file only.

First we need to validate that this .skb file actually exists in the specified relative path, otherwise we exit, as we don't want to compile non-existent files.

Once we validate that the file exists, then we can check whether the compiled HTML file will have the same name ( 14) as the Skribilo file or not ( 12). In either case, we need to run Skribilo's compiling command, hence the use of formatted strings, that way we can include the corresponding argument in the command.

Compiling all files

Now let's get into the fun part, compiling all Skribilo files at once!

For starters, we need to find all the paths to the .skb files, so that we can compile them one by one later ( 17). When we iterate, we must do two main things:

  • Use Path.resolve(), to turn our relative paths into absolute ones, and avoid issues when iterating.
  • Use Path.rglob(), to recursively look through subdirectories. In our case, this is necessary, our subdirectory posts/ contains all of the journal entries, and we wish to compile those as well.

The other main thing we need to do before we iterate is saving the CWD ( 18). We will be changing directories in each iteration, so we will need to always change back to our CWD, to ensure we access the correct path for each individual file. I.e., compile a file that actually exists, and adding the compiled result to the correct place.

Now that we have the paths, and the CWD, we can begin iterating through each .skb file that exists. In making this program, I realized Skribilo has strange behavior with files that contain images (or rather, files that are referenced from a different directory). Let me explain, some of my posts have images in them, giving me a file structure like this:

  • imgs/
    • ref-img.png
  • posts/
    • src-post.skb
  • script.py

It seems like if I have such cases, in which I need to reference a file in a different directory, I must run the Skribilo compiling command from where the main file is (that is, posts/). If I try to run it, it will throw an error once it attempts to link the image, indicating that it can't find it, despite being correctly linked with its relative path (i.e. "../ref-img.png").

Due to this quirk, I had to find a way around it, which is where os.chdir ( 21) comes into play. Every time we encounter a file, we will update our CWD to the .skb file's parent directory (i.e. posts/). That way, the posts that may contain images always are compiled and rendered correctly. ( 22).

Once the current iteration is done, we must reset CWD to our original one, which we saved previously. This will allow us to begin the next iteration from where the script is, ( 26), ensuring every file is accessed from the same relative starting point.

a

(made with skribilo)