The notes in Dendron are stored in a so-called “vault” in a flat structure with “dotted” filenames that represent the hierarchy of the note. An example file name would be: reference.computers.setup.docker-install.md with the hierarchy being self-evident in the naming scheme. Each note is in MarkDown for the most part, with some Dendron-specific syntax thrown in for features like wikilinks, transclusion etc.

https://github.com/sagarbehere/dendron-hugo-export/blob/main/export-hierarchy.py

This script

  • Looks at all files in the Dendron vault (only top level, not subdirs) whose name ends in .md
  • Extracts a filename like pqr.abc.xyz.md into
    • An export_fname xyz.md
    • A export_dir pqr/abc/
  • If the export_fname or export_dir are part of an exclusion list, they are excluded
  • Populates an sqlite database table, named files, with the dotted file name pqr.abc.xyz.md and its corresponding exported path pqr/abc/xyz.md
  • Copies the file from the Dendron vault to the correct folder in exported hierarchy
  • moves e.g foo/bar/baz.md to foo/bar/baz/_index.md if foo/bar/baz exists
  • moves root.md to content/notes/_index.md
    • And adds title, cascaded type, a nav bar menu entry to the frontmatter
  • Adds a date field to each note’s frontmatter
    • Date matches the updated variable in Dendron frontmatter, if it exists. Else
    • Date matches the created variable