
Taking Notes with Emacs Org Mode and Org-Roam

Peter Prevos |
2634 words | 13 minutes
Share this content
Taking notes is an important activity for all creative work. Recording your thoughts and ideas or somebody else’s ideas is 2a foundational activity whether you write scientific articles, novels or whatever else. Emacs Org mode has some useful functionality to take notes, which can be further extended with the Org-Roam package. This article explains how to take notes in Emacs and configure the Org-roam note-taking system for Emacs.
Org Roam is a popular note-taking package that uses Org mode as its central repository. The disadvantage of this package is that it relies on a database and can only manage Org mode files. This page assumes that you are using the latest version of Emacs, which at the time of writing is 29.1, which has a built-in database. This page is no longer maintained as Emacs Writing Studio uses Denote for notetaking.
Single File or Personal Wiki
Taking notes in Org mode can be as easy as maintaining one or more files with many headers. Org mode has some functionality to tag each heading to help you categorise notes.
While this is a great start, keeping topical notes in separate files is a more productive method because you can easily link Org mode files to each other, creating a personal Wiki. To create a hyperlink between two files, press C-c C-l
(org-insert-link
) and type file:
(Or add the universal argument C-u C-c C-l
to choose file links by default). You can then select the file with your completion system and type a description, which creates a hyperlink. You follow these links by pressing C-c C-o
.
This method allows you to navigate from one file to the next, but Org mode does not know which other files link to your current buffer. There is no database in vanilla Emacs that allows you to review the structure of your linked files.
The Org-Roam package extends the Org mode functionality by saving all the links between files and headings in a database. This method allows you to also view the backlinks. The database stores a list of nodes, which are files or registered headings. This additional functionality allows you to navigate through your network of notes like you would in a personal wiki.
Zettelkasten: Structured collection of notes
Org-Roam implements the principles of the Zettelkasten method as a digital slip box full of cards. German sociologist Niklas Luhmann maintained a collection of tens of thousands notes, each written on an index card. These cards were linked through a series of keywords. This method allowed Luhmann to connect disparate ideas and writes his extensive oeuvre of books and articles.
The Org-Roam package in Emacs creates a network of links between your notes and manages your digital knowledge garden. Basically, the package extends Org mode functionality by storing all nodes (files and registered headings) in a database, including which between nodes. Furthermore, Org-roam provides each node in your knowledge network with a unique identifier consisting of a long string of numbers and letters, e.g. 711a7cac-e46b-4e64-b1e6-2940fa431e55
.
The Org-Roam database provides excellent opportunities to analyse your network and discover patterns in your research that were perhaps previously invisible. You can examine this database and visualise its structure. The graph below is created with the igraph package in R.

The package provides a lot of freedom to structure your personal Wiki, and this article describes the basic functionality. However, before we can get started, we need to configure the system.
Configuring Org-roam
Install database
The Org-roam package stores a summary of all nodes in your network in a database. In Emacs version 29.1, this functionality comes out of the box and no further configuration is required.
If you are using an older version of Emacs, then Org-Roam depends on the EmacSQL package to connect with the database. During package installation EmacSQL needs to compile a custom native binary for communicating with the SQLite database.
To enable this task, you will need to install a compiler on your system. On GNU/Linux systems, including Chromebook, you need to instal the GCC compiler through your favourite package manager.
On Windows you need to install Chocolatey. Open PowerShell as administrator and follow he instructions on the Chocolatey website. After Chocolatey is available, you can install the compiler in Powershell as administrator with:
choco install mingw
When Emacs configures the Org-Roam package, it will try to compile the database connector. This might take a little while, but is only done once.
Configure Org-Roam
The Org-roam package requires some configuration to get it to work. At a minimum, we need to activate the package, bind some keys, define the folder where your notes and database will live and set a template for new notes.
You will also need to install the use-package
package, which the configure Emacs article discusses. Alternatively, you can download the complete init file for this series of articles from GitHub and store it in your configuration folder.
You will also need to install use-package, which is explained article on how to configure Emacs.
;; Org-Roam basic configuration
(setq org-directory (concat (getenv "HOME") "/Documents/org-roam/"))
(use-package org-roam
:after org
:custom
(org-roam-directory (file-truename org-directory))
:init
(org-roam-setup)
:bind (("C-c n f" . org-roam-node-find)
("C-c n r" . org-roam-node-random)
(:map org-mode-map
(("C-c n i" . org-roam-node-insert)
("C-c n o" . org-id-get-create)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
("C-c n l" . org-roam-buffer-toggle)))))
The first line defines the default file for Org mode files. I store my Org-Roam notes in /Documents/notes/
in my home folder. You need to change the name of the folder to your personal preference. The (getenv ““HOME””)
part of this configuration is your home folder, so you only need to modify the relative path between quotation marks.
The org-roam-setup
function initiates the database, which can take a while the first time round if you have many existing notes.
Lastly, the configuration defines the keyboard shortcuts. The first three shortcuts are added to the overall keyboard map, so you can activate it from anywhere in Emacs. The last five lines are only valid when you are in an open Org mode buffer. Note that all shortcuts start with C-c n
to provide consistency.
Creating and Taking Notes
We are finally ready to write notes. You add a new note with the org-roam-node-find
function (C-c n f
). You can type the name of an existing note or of a new note. The minibuffer completion system, which we configured earlier, shows a list of available nodes and filters options as you type.
When you create a new node, it will open in an Org mode capture screen. You complete the node with C-c C-c
and cancel it with C-c C-k
. You can read these instructions in the top of the popup screen. When you complete the node, Org-Roam will construct a filename and save it to disk. The filename starts with a timestamp, followed by the name of the note, separated by dashes. There is need to worry too much about the filename because you will be retrieving nodes through their title and tags, rather than a filename.
An Org-Roam file (called a node) is just another Org mode file with some minor differences. The file starts with a properties drawer that defines the file ID. Using an ID instead of a file name makes it easier to maintain link integrity when you change file names or titles. A node can also contain one or more aliases, so you can search on multiple names.
The remainder of the file contains the header and content. Note the #+filetags:
property. A file tag is a way to add tags to files so you can easily group entries. The tags are displayed after the title or alias when you find a new or existing file.
When you first create a new file, a capture screen appears where you can write your note. To save the note to your system, press C-c C-c
, to cancel creating a new note, press C-c C-k
.
:PROPERTIES:
:ID: f1bdb099-2184-46cf-a952-4808baa00b09
:ROAM_ALIASES: "Note taking with Org-roam"
:END:
#+title: Zettelkasten method with Org-roam
#+filetags: :notes::emacs:
* First headline
If this file exists in your database, you will be able to find it through its title, alias or tag. An alias is useful for registering synonyms of words or definitions of abbreviations (AI / Artificial Intelligence). File tags help you cluster notes by topic.
Your note starts below your header. If you are new to Org-mode, then read the article on distraction-free writing.
Org-Roam Nodes
In Org-roam terminology, a file or a registered heading is a node in a network. You can promote a heading inside a file to a node by pressing C-c n o
(org-id-get-create
). This will create a property drawer below the heading with an id tag. Use the TAB
key to open or close the drawer. Drawers are an Org mode functionality to store metadata about files or headings.
Org-roam indexes every node (file or heading with an id) that resides in its designated folder and subfolders in a database. This database contains metadata about the node, such as its title and any links from and to the node.
Tags and Aliases
To make it easier to group and find nodes, you can give it one or more alias titles with the C-c n a
shortcut (org-roam-alias-add
). The main and the alias titles are searchable when finding a node. The name of the alias stored in the drawer at the start of the file.
To add one or more tags to a Org-Roam file, use org-roam-tag-add
(C-c n t
). Note that tags have completion using the TAB
key. Tags are also searchable when visiting a node. Tags are a way to add structure to your nodes by adding them to a group. Adding a tag to a heading is as easy as hitting C-c C-c
, which is a standard Org mode function.
Linking Nodes
The second method to add structure is by linking nodes. You can start writing your note as per usual. Links to existing files are easy to insert with the C-c n i
shortcut (org-roam-node-insert
). Search for the file you want to link to and hit enter.
As your nodes grow in number, you slowly build a personal knowledge network. Org-Roam has graphing capabilities, provided you have the Graphviz package installed, which is outside the scope of this article. The org-roam-ui package provides an interactive graphical interface to your node network through your browser.
Discovering Nodes
If you like to know which files link to the buffer you are currently editing, then use org-rosm-buffer-toggle
(C-c n l
). A new window appears with a list of all files that link to the current buffer. Move to the window with org-open-at-point
(C-c o
), select your node, and hit ENTER
to open the note. To close the backlinks window, use C-c n l
again.
My favourite function is to open a random note. Pressing C-c n r
(org-roam-node-random
) opens a note and invite you to take a random walk through your knowledge garden.
Note Templates
The default new node only has a property drawer and a title and the filename starts with a timestamp. You can of course change this default behaviour by setting the org-roam-capture-templates
variable.
For example, this configuration creates a new default node with a filename and a template head (file+head
).
The file name is based on the title slug (${slug}.org
), which is basically the node title in lower case, with spaces replaced by dashes.
The first lines of the head of this node contain the title, the creation date and a #+lastmod:
entry, which you can use to store the date it was last saved. To make this happen, you also set the time-stamp-start
variable.
The immediate-finish option bypasses the capture system and creates a new file without .
(setq org-roam-capture-templates
'(("d" "default" plain "%?"
:if-new
(file+head "${slug}.org"
"#+title: ${title}\n#+date: %u\n#+lastmod: \n\n")
:immediate-finish t))
time-stamp-start "#\\+lastmod: [\t]*")
The template functionality in Org-Roam is extensive, so I will leave it at this example. You can add additional lines to your node template after the title or lastmod entry in this example. The \n
indicator denotes a new line.!
Bibliographic notes with Org-Roam
Managing a large collection of literature, electronic files and associated notes is one thing, but if you can’t quickly find them then you might as well not have them at all.
The Helm completion system provides a useful window to your bibliographies. The Helm BibTeX menu lets you search entries and act on the results. The C-z
key provides a menu for further actions, such as viewing pdf files or adding and editing notes.
Emacs will open any associated PDF files. When you select to take notes, Emacs will create a separate Org mode file for the selected reference. When you also use Org-Roam for taking notes in Emacs, then you have a complete research management system that creates hyperlinked and tagged bibliographical notes.
The setup below provides a minimal configuration that uses the folder names defined above. Use C-c n B
to start Helm BibTeX.
(use-package helm-bibtex
:config
(setq bibtex-completion-bibliography bib-files-directory
bibtex-completion-library-path pdf-files-directory
bibtex-completion-pdf-field "File"
bibtex-completion-notes-path org-directory
bibtex-completion-additional-search-fields '(keywords))
:bind
(("C-c n B" . helm-bibtex)))
The paths in the file
field in a BibTeX file can contain one or more filenames, separated by a semi-colon. When you start the filename with a colon, you can use a relative path, e.g.: file = {:/path/to/article.pdf}
is the same as ~/Documents/bibliography/pdf/path/to/article.pdf
, i.e. the colon symbol stands for the content of the pdf-files-directory
variable we defined in the previous section.
The bibtex-completion-additional-search-fields
includes the keyword as a search field, which makes it a bit easier to find stuff.
The first time you start Helm BibTeX might take a few seconds as it parses all entries in the collection of files, depending on the size of your bibliography. Just like all Helm applications, the interface uses incremental search, so just start typing and the bibliography will narrow.
The helm-bibtex website provides detailed information about further functionality.
Org-Roam BibTex Package
The org Roam database can also connect to a bibliography in the form of a collection of BibTeX files. This last configuration connects your bibliography to the Org-Roam database. The Org-Roam BibTeX package allows you to create notes directly from your bibliography. The only difference between a regular note and a bibliographic one is that the properties drawer contains a citation link in the ROAM_REFS
property, as shown in the example below.
:PROPERTIES:
:ID: c037d9f7-1aad-4774-8f8e-d5974de23b8c
:ROAM_REFS: cite:harris_customer_2001
:END:
#+title: Customer participation in retail service: Lessons from Brecht
You can view the associated PDF file from anywhere in the document with the C-c n b
shortcut, which will open a menu with options.
(use-package org-roam-bibtex
:after (org-roam helm-bibtex)
:bind (:map org-mode-map ("C-c n b" . orb-note-actions))
:config
(require 'org-ref))
(org-roam-bibtex-mode)
Taking Notes with Org Roam
This is a short introduction to getting you started with Org-roam. There are lots of opinions on how to structure your personal knowledge network. My approach is organic, and I have imported all text files stored in various places in the Org-roam folder. I now have my third brain hemisphere available at my fingertips, thanks to the great work of the Emacs, Org mode, Org-Roam and Deft developers.
The following article in this series outlines how to manage bibliographies in Emacs and link these to Org-roam.
All the configuration explained in this series of articles is available as an init file on GitHub.
Emacs is a malleable system, so everybody will have their personal preferences for undertaking a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the contact form to send me an email.
Share this content