Ric Raftis consulting logo

Ric Raftis Consulting

How to Create a Map of Content (MOC) using Dataview in Obsidian

Ric Raftis consulting logo

One issue with Obsidian that I have found is you can’t see a body of related work all in the one place. You can search on tags or aliases, but this will return a list in the left-hand column to scroll through. It is designed to select notes as opposed to an index of related notes.

I found this frustrating, particularly with the articles I write, for example. It is handy to look through an index note to see what I have already written. It can save me writing another article on the same subject without referring to one I have already published. Another aspect is that looking through the index can spark some ideas for other articles.

Of course, articles are not the only area where such an index page is useful. How can you see a list of all the books you have read? Perhaps some inspirational quotes?

The solution is a Map of Content or (MOC). I cannot say for sure where the term originated, but my first exposure to it was through Nick Milo of Linking Your Thinking. If you break down the term, Map is the index or table and the Content is the collection of notes being indexed. The MOC is effectively collating all the notes relating to a particular subject or theme in a singular higher level note. By creating your MOC using linked notes, you are creating a jumping off point into the deeper levels of your project.

I like to automate whatever I can to save time. Automation can also help with forgetfulness, such as being flat out and forgetting to link a note back to an MOC. So I create my MOCs using a callout and a dataview function to add a note automatically to the MOC.

Using Tags

There are two ways of using tags within an Obsidian note. You can use them in YAML front matter and the link will explain this further. The other way is with the hash (#) followed by text which you can use at the top of the note in the metadata or in the note’s body. My preference is the latter but you will work out which is best for you. You will find plenty of discussion on the subject in the Obsidian Forums. The following details on setting up the MOC are based on the second method.

Steps to Creating an MOC

Setting up a Note Template

  1. It pays to start with a template of some description for your notes. It can be for any purpose. I have templates for general notes, articles, videos and meetings, for example.
  2. In the template, make sure you have provision for an uplink and tags. Personally, I use both. They are setup as follows
  1. Here is an image of my note template showing the metadata section.

Image showing code for metadata in Obsidian template

Image showing code for metadata in Obsidian template
Obsidian Note Template metadata. Image by author
  1. For explanation, Obsidian inserts the date and title automatically when you apply the template to a fresh note.
  2. In up:: I will enter the Map of Content where the note belongs as a link. If I am undecided, I will leave it blank.
  3. Under tags:: I will place the tags relating to the article such as #article #article/to/write etc. Which is tagging my note that it’s about an article I have to write.

Creating the MOC

The Dataview community plugin for Obsidian will create your MOC. If you don’t have this plugin, you will need to install and enable it. It has many, many more uses than the one described here and is essential for Obsidian, in my view.

Open a fresh note and call it (we will use Articles for an example) MOC Articles
In the up:: area, I would suggest taking this back to your Home note if you have one. This would be the highest level note in your vault allowing you to drill down into the nether regions.

As a tag, you could use #map

Before creating the actual index or table, write a description of what the MOC is about, what belongs here, memory joggers about what you should do when looking at it. For example, are you generating any ideas? Does one title spark a link to something else you need to explore?
Now enter the code to generate the table. Again, we are using articles as the example.

Dataview code in an image for readability by author
Dataview code in an image for readability by author

This will display all articles linked to the MOC and with a tag of article or any sub tag of article as well.

Dataview allows you to drill down even further and create separate tables or lists on your MOC. For example, in the FROM line, you could delete the MOC Articles link and place the tag #article/to/write. This would then display a list of all notes you have where you are intending to write articles. Changing that line to FROM #article/written would render a list of all the articles you have written. You could very well have both tables in your MOC.

Below is an image showing the result of using a dataview query to build a table. You can also use these in callouts so they can be folded or collapsed in your note.

an image showing the result of using a dataview query to build a table.


The method I have described is the one that works for me, but I am sure others have methods that work just as well. The most important issue is to start with something and you can build and change it from there as your skills grow. As an example, while writing this article, I modified the dataview code in my MOCs, as I now have a better knowledge of the syntax.

I certainly hope this has been helpful and if you have questions, then leave them in the comments below and I will do my best to provide an accurate answer.

EDIT: 16 Feb 2023. Although the dataview code and everything else in this article works fine, I have since realised I have been doing my Maps of Content incorrectly in terms of structure. You can read my follow up article at I Have Been Doing My Obsidian Maps Of Content (MOCs) The Wrong Way


Leave a Comment

Your email address will not be published. Required fields are marked *