Dendron is a fantastic note taking application. Its approach to flexible hierarchies really resonates with me and I use it as my primary Personal Knowledge Management (PKM) tool. The notes in my Digital Garden are a subset of the notes I keep in Dendron. This is a description of how I export a subset of notes in Dendron for publishing with Hugo and the associated scripts.

The first stop for publishing Dendron notes is Dendron’s own Publish feature. It does a reasonably good job of exporting notes to a static website and the resulting static website has its own distinctive visual appearance and early-stage UI quirks. Therefore, it may not be for you if you wish for the visual appearance of your published notes to be tightly integrated with the rest of your site.

Dendron provides for a way to export notes to a set of pure Markdown files organized in a set of folder hierarchies, via its Markdown Export Pod. This can be an excellent starting point for publishing the notes with Hugo. However, you’d still need to tweak the notes’ content in Hugo-specific ways.

In order to have full control over the export process, I wrote some quick-and-dirty Python scripts to export selected notes from a Dendron vault directly into a hierarchy of files and folders readily consumable by Hugo.

WARNING: The scripts are extremely immature. They were cobbled together by copy/paste’ing code from StackOverflow and may fail without warning in all sorts of edge cases. I stopped working on them as soon as they started working for my own use cases. :)

The scripts

  • Export notes from a Dendron vault into a hierarchy of files and folders

    • Exclude a configurable set of hierarchies and files
    • Create _index.md​ files within folders as needed by Hugo
    • Add the date​ frontmatter variable to each exported note, so that Hugo can set the publish date
  • Process internal wikilinks in Dendron notes into a format preferred by Hugo: [label]({{< ref "path/to/file.md" >}})

    • I exclusively use wikilinks for inter-note linking in Dendron
  • Add a ‘Backlinks’ section to each note that contains a list of notes that link to the current note

  • Do not support the features of Dendron that I do not use (e.g. Transclusion)

    • Only wikilinks and links to image files are supported, as of now.