How My Braindump Works



I have a braindump that is auto generated from my Org Roam Knowledge Base. This is a short description on how it works, and some extra goodies including:

UPDATE: I have switched to ox-hugo, therefore the exact script mentioned is obsolete. However, the newer script is very similar, and follows from the same concept.

The Org Roam Knowledge Base

My Org Roam directory lives at /Files/org/roam. It consists of:

A small preview of the root directory:


A small preview of the daily/ directory:

Setting What Files To Export

I use Org Mode Tags to set what files to export and where. Currently:

Note that I prefix these with an underscore (_), for better mental separation between normal tags and those intended to be processed using a script.

The Export Script

To export the (selected) notes to my braindump and/or blog, I use the following script which uses orgparse to figure out which notes have the relevant tags:

#!/usr/bin/env python

import os
from sys import argv
import shutil
from glob import glob
from orgparse import load

roam_directory = os.path.join(os.path.expanduser("~"), "Files", "org", "roam")
roam_directory_files = glob(f'{roam_directory}/*.org')

braindump_directory = os.path.join(os.path.expanduser("~"), "Files", "org", "", "braindump")
blog_directory = os.path.join(os.path.expanduser("~"), "Files", "org", "", "blog")

for roam_directory_file in roam_directory_files:
    file_path = os.path.join(roam_directory, roam_directory_file)
    roam_node = load(file_path)
    # You can add more tags and directories, make a single tag export to multiple directories, etc.
    if "_public" in roam_node.tags:
	shutil.copyfile(file_path, os.path.join(braindump_directory, os.path.basename(file_path)[15:])) # [15:] removes the timestamp
    if "_blog" in roam_node.tags:
	shutil.copyfile(file_path, os.path.join(blog_directory, os.path.basename(file_path)[15:])) # [15:] removes the timestamp

This script is also hosted on my scripts repository.

Note that this script won’t work out of the box for encrypted notes. You would have to first decrypt notes with filenames ending in .org.gpg into a temporary directory, and then parse them. However, encrypting notes that you intend to publish seems futile to me, and thus I haven’t dabbled with it yet.

The Website Directory

You might have noticed that the above scripts copies the notes to ~/Files/org/ under braindump/ and blog/ respectively. These can be customised, and will be static site generator specific. You also might want to run these files through ox-hugo if your static site generator doesn’t support Org files. My website generation process is out of the scope of this post. You can check it out in the links section though.