Finding "ghost notes" in Obsidian

tl;dr and geeky

It’s a common practice in Obsidian to refer to non-existing, some say “ghost notes”, in the text of a note. This is simple to do. Merely refer to a topic, or concept, or whatever, with double-bracketed content like this

[[perpetual motion]]

This is the same syntax used when referring to an existing note, but if the reference point to a non-existent note, then Obisidian will not create the note unless it is configured to create it by clicking the reference.

Why do this? The main reason, in my use and suggested by various PKM or MOC essayists, is to point to a concept as you take notes, but not create the target note. This will show up in graph views, with links to all the cases where the [[perpetual motion]] reference is used. If you want to go ahead a create that reference note, then just click it on the graph. This is part of building reference maps, or MOCs.

The downside of course is it’s not easy to figure out where all those double-bracketed cases are in an an Obsidian vault. You can browse the graph, but that can take a lot of time. I ran across a post in Obsidian’s forum from @JLDiaz that solves the problem neatly. This requires that the Dataview plugin is installed.** If installed, then include JLDiaz’ Dataview snippet in a note:

let d = {}
function process(k, v) {
  Object.keys(v).forEach(function (x) {
    x = dv.fileLink(x);
    if (d[x]==undefined) { d[x] = []; }
	.forEach(([k,v]) => process(k, v));
dv.table(["Non existing notes", "Linked from"],
         Object.entries(d).map(([k,v])=> [k, v.join(" • ")]))```

I won’t parse how that works – it does – but the result is a two-column table. First column lists the “non-existing” note names, the second column lists all the notes that link to that non-existent note. I use this a a tickler to see I should go on and create the reference note, and as a way to clean up the vault. Not-infrequently things get pasted into notes in the vault that contain double-bracketed text that I don’t want – for example, when pasting from Wikipedia. Using the report created by the plugin, I can find these cases, click on the note that needs to have the reference removed, and fix it.

It’s also an eye-opener to see the mistakes that creep into a vault and have the info to fix them.

I advise putting this snippet in a stand-alone note in the home folder, if you have one. If the vault is large – lots of notes – it can take a few seconds or even minutes to process all the notes.

** Admitedly a strong opinion about this, but Dataview is by far the best reason to use Obsidian, IMO.


Very helpful, thanks for posting!

1 Like