Displaying Hierarchical Lists of Files With Obsidian and Dataview


In Obsidian, I use a folder of notes called “Collections”. Inside Collections are various folders that act as buckets of info, in a quasi-Zettelkasten notes-as-personal-wikipedia kind of thing.

My Collections currently include (in alphabetical order):

  • Articles
  • Committees
  • Ideas
  • Institutions
  • Organizations
  • People
  • Profiles
  • Topics
  • Vendors

Some of these have subfolders to organize notes into smaller buckets. For example, Topics is organized by folders for:

  • General Tech
  • Higher Education
  • Information Technologies
  • Learning Spaces
  • Learning Technologies
  • Misc
  • Pedagogy
  • Processes
  • TI Projects
  • UCalgary

The folders change and I add to them and reorganize as needed. I’ve only been using Obsidian for about 4 months now, so I figure things will continue to settle as I get deeper into it…

This works well, and I can link to these notes from anything in my Obsidian vault. And the links power the Graph view, which helps me make sense of the connections:

Graph view of connections between the notes in my Obsidian vault

I use a canvas as my “home base” in Obsidian. On the dashboard, I have several notes displayed so I have ready access to about 500 organized notes at a glance.

screenshot of my Obsidian canvas home base

It’s a little too small to see in the screenshot, but one of those notes is a special “utility” note that I’ve created, containing a dataview snippet to show all notes within the “Topics” collection. Previously, I could only figure out how to list the files across all subfolders, sorted alphabetically. Useful, but clumsy.

I had been using a dataviewjs hack to kind of approximate hierarchical file listings, but it was ugly and the results were weirdly formatted.

But - I just spent some time in the dataview documentation and, with a bit of trial and error, came up with a way that does almost exactly what I want. So, the “Topics” list went from being a flattened list of all topics, to one that’s properly grouped by folder (folders sorted alphabetically), with the files also sorted alphabetically. (I say “almost exactly what I want” because I can’t figure out how to clean up the folder names, so they’re all displaying the full hierarchy for each folder - not the end of the world, but takes a lot of space and is redundant for my use.)

Here’s the dataview snippet that I use for the Topics utility note that is then displayed on the main Canvas:

dataview
list rows.file.link
FROM "Collections/Topics"
sort file.name asc
group by file.folder
sort file.name asc 

And here’s what the snippet looks like, in utility notes embedded on my main Canvas (showing similar dataview snippets for Institutions and Topics):

screenshot of part of the Institutions and Topics dataview notes on my main canvas

I’m also using the MCL Multi Column css from Faiz Khuzaimah to present the dataview lists in 2- or 3-column displays.


Update: an hour after I posted this, I saw a link to a new (and very useful) interactive dataview query builder linked on the Obsidian subreddit. It gets you almost to the same place as my snippet, but gives you options to customize it. That’ll come in handy…


comments powered by Disqus