Note Link Janitor

Backlinks maintained using Andy Matuschak’s note link janitor

This script reads in a folder of Markdown files, notes all the wiki-style links between them, then adds a special “backlinks” section which lists passages which reference a given file.


  1. Links are formatted <a href="">like this</a>.
  2. Note titles are inferred from the first line of each note, which is assumed to be formatted as a heading, i.e. # Note title.
  3. All .md files are siblings; the script does not currently recursively traverse subtrees (though that would be a simple modification if you need it; see lib/readAllNotes.ts)
  4. The backlinks “section” is defined as the AST span between ## Backlinks and the next heading tag (or <!-- --> tag). Any text you might add to this >section will be clobbered. Don’t append text after the backlinks list without a heading in between! (I like to leave my backlinks list at the end >of the file)


note-link-janitor /Users/andybyers/Developer/notes-ajb-app/notes

Make this into a chron job

0 12 7 * 3 note-link-janitor <path to /notes>