Building Out Your Roam Part 2: Questions, Queries, and Block References

Building Out Your Roam Part 2: Questions, Queries, and Block References

Part 1 of this series on building out Roam Research discussed the relationship between page references and linked page references. We used page references in the form of a tag (#Questions) to track open and answered questions by utilizing "linked references" and filtering. If you haven't read Part 1 yet, please go ahead and check it out. This article builds upon the previous discussion.

Questions Page
Questions Page

While "linked references" are immediately helpful, I believe there is a better way to visualize and track open questions or anything else you may want to track in your Roam database. Let's build upon what we have created so far. As promised in the previous article, I will discuss why we created the "Open Questions" and "Answered Questions" blocks on the Questions page.

Finding Blocks with Queries

The "Open Questions" and "Answered Questions" blocks on the Questions page would serve as headers for a couple of queries that we will use to surface our questions (open or answered).

Basic AND Query

This article is not a comprehensive lesson on queries. For a quick primer, I usually point people to an article on Roamhacks called "How to query in Roam."

To begin, we will use a basic "AND" query by indenting a block under the "Open Questions" block and typing /query, and selecting the "Query (and)" option.

Query Menu
Query Menu

An example query will show up in the block. Replace it with the following:

  • {{[[query]]: {and: [[TODO]] [[Questions]]}}}

When you click outside the block, Roam should present you with any blocks that are a "TODO" AND have the "Questions" tag.

Query: TODO and Questions
Query: TODO and Questions

Next, construct a similar query for "Answered Questions" and place the block indented under the "Answered Questions" section. The query should read:

  • {{[[query]]: {and: [[DONE]] [[Questions]]}}}
Query: DONE and Questions
Query: DONE and Questions

If you tick the checkbox next to any question, Roam will now surface the block in the "Answered Questions" section of your "Questions" page.

Done Item in Query
Done Item in Query

It does not matter where you write the question in your database. If it is a "TODO" that has the "Questions" tag, it will surface on your "Questions" page with these queries.

In the previous article in this series, I discussed blocks as the most crucial element in Roam. The block's flexibility and power will become evident when you create your first block reference.

Creating a Block Reference

The easiest way to create a block reference is to right-click on the block you would like to reference and select "copy block ref" from the context menu.

Copy Block Reference Menu
Copy Block Reference Menu

You can paste the block reference anywhere else you would like. For this example, I will paste the block reference as the first bullet in a page titled "Block Reference Test." When you first paste it, you will see a block ID generated. If you click outside the block, you will see that it references the original block.

Block Reference Block ID
Block Reference Block ID
Block Reference Text
Block Reference Text

When the contents of the original block change, any reference to that block also changes. This functionality allows you to have a single source of truth for the content while referencing the same content anywhere in your Roam database.

Block Reference Text Change
Block Reference Text Change

You will also notice a number appear to the right of the original block. This number shows how many times you reference that particular block in your Roam database. If you click on that number, it will show you where the block reference location is in your database. You can then expand the reference for more details. This functionality is called an "inline block reference."

Inline Block Reference
Inline Block Reference

Exploiting Inline Block References for Navigation

Inline block references remind me of a collapsable context menu. We will take advantage of that fact and build a simple navigation structure in our "Life" page to navigate to our "Open Questions" and "Answered Questions." Follow these steps to create the "inline block reference" navigation menu.

  • Open the "Life" page in the right sidebar by shift-clicking the "Life" page reference under "Shortcuts" in the left sidebar. You can also start typing "Life" in the "Find or Create Page" search bar and shift-click on the "Life" item.
  • Open the "Questions" page in the main window by searching for "Questions" in the "Find or Create Page" search bar.
  • In the "Life" page in the right sidebar, right-click the "Questions" tag block and select "copy block ref" from the menu.
  • Paste the block reference so that it is indented directly under "Open Questions" and "Answered Questions" on the Questions Page. You can also use alt(cmd for mac)-drag the block to the desired location to create a block reference in that location.
Using Block Reference to Create Navigation
Using Block Reference to Create Navigation

Now, as you work in your "Daily Notes" page, if you keep the "Life" page in the right sidebar, you can access your "Open Questions" and "Answered Questions" by clicking the number for the "inline block references" next to "Questions" under the "Life" page. After the "inline block references" open, you will click the "Open Questions" or "Answered Questions" depending on what you want to see.

Inline Block Reference for Open Questions
Inline Block Reference for Open Questions
Inline Block Reference for Answered Questions
Inline Block Reference for Answered Questions

Conclusion

This article discussed using queries to find what you need in your database and block references to reference any block anywhere in your database. Then, we added a simple navigational structure to our Roam database by utilizing the block reference functionality. I hope that you will see the flexibility and power of blocks in Roam from this small exercise. Using the block reference navigational framework shown here, you can build out your navigation while hiding the complexity when you don't need it. The next article in this series will build upon the navigation by adding some templates for projects and meetings.

Harley Stagner

I'm an IT professional working in technical marketing. I truly believe that our thoughts are the most unique asset that we can offer to the world. This will be a curated collection of mine.