Published

February 20, 2025

Exporting a vault

Exporting a vault in three quick steps

1. Create a Vault. We’ve predefined a variable named root to point to the base directory of this repository, and will use a sample Obsidian vault in the repository’s test/data directory.

using Obsidian
vaultdir = joinpath(root, "test", "data", "presidents-vault")
v = Vault(vaultdir)
"Obsidian vault with 13 notes"

2. Define a destination directory.

outputdir = joinpath(root, "scratch", "presidents-vault-export")

3. Export the vault to the destination.

exportmd(v, outputdir)

What just happened?

To see how Obsidian notes are convereted to Markdown files, let’s compare the contents of the source file for Abraham Lincoln with the corresponding output file.

Tip

exportmd has several optional parameters that let you control how obsidian tags, dataview key-value properties, yaml headers, and output file names are treated. See the guides (cookbooks) section of the documentation for full examples.

The source file

This code prints the contents of the original Obsidian note:

srcfile = path(v, "Abraham Lincoln")
read(srcfile,String) |> println
---
tags:
    - president
---

#assassinated

Last name: [[Lincoln]]

Honest Abe was the (hiddensequence:: 16) sixteenth president [sequence::16].

The output file

The Markdown export maintains the directory structure of the Obsidan vault. Looking at the path of the Obsidian note for Abraham Lincoln, I saw that it was placed in a directory named people, so the Markdown output will be in a people subdirectory of the export root. By default, names of output files replace spaces with underscores, and use quarto’s .qmd extension, rather than Obsidian’s .md,

With that in mind, we can use the following code to print out the Markdown export:

outputfile = joinpath(outputdir, "people", "Abraham_Lincoln.qmd") 
read(outputfile, String) |> println



Last name: [Lincoln](./../last-names/Lincoln.html)

Honest Abe was the sixteenth president.

What changed?

As you can see in the first line of the output file, the original wikilink [[Lincoln]] has been converted to a normal Markdown link using

Using the default values for exportmd’s optional parameters, the following parts of the source file have been removed:

  • YAML header, here including defintion of an Obsidian tag president
  • inline Obsidian tags (#assassinated)
  • dataview key-value properties, in both hidden ((hiddensequence:: 16) and visible ([sequence::16]) formats

All of these data values are available from the Vault object, v. Here are the Obsidan tags:

tags(v, "Abraham Lincoln")
2-element Vector{String}:
 "#assassinated"
 "#president"

Here are the dataview properties (key/value pairs):

kvpairs(v, "Abraham Lincoln")
2-element Vector{Any}:
 (k = "sequence", v = "16")
 (k = "hiddensequence", v = "16")