DEV Community

Cover image for Turning Markdown Files into a Queryable Knowledge Graph
Javier Ramírez
Javier Ramírez

Posted on

Turning Markdown Files into a Queryable Knowledge Graph

Markdown files often contain more structure than we give them credit for.

With YAML frontmatter and consistent links, a collection of Markdown files can behave like a small knowledge graph.

Many people already use YAML frontmatter to store metadata:

---
id: mission-klendathu
type: mission
commander: [[johnny-rico]]
date: 2297-08-01
---
Enter fullscreen mode Exit fullscreen mode

Once files have consistent IDs and links between them, something interesting happens:

  • files become nodes
  • [[links]] become relations
  • the collection of files becomes a graph

Querying Markdown

One approach is to define queries directly inside Markdown files.

If you can query that graph, Markdown stops being just documents — it becomes structured data.

For example:

!view mission where commander = [[johnny-rico]]
select date, outcome
sort date desc

The query runs over all Markdown files and returns matching nodes.

In my case, I tried building a VS Code extension to explore this idea.

Live Query Results

!view queries render results as tables inside the editor.

You can edit values directly in the table, and the changes write back to the YAML frontmatter of the source file.

Live query table in VS Code with inline editing of YAML frontmatter

Why Markdown?

Yamlink

The goal is to keep everything:

  • local-first
  • Git-native
  • plain Markdown

No database, no lock-in — just structured files.


Yamlink

To explore this idea, I built a VS Code extension called Yamlink.

If you're curious:

GitHub: https://github.com/javierigaciorm/yamlink

VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=yamlink.yamlink

I'm especially interested in hearing how others are working with structured data in Markdown.

Top comments (2)

Collapse
 
jrmhng profile image
Jeremy

Hi there, I've come across Yamlink because I realised that with VS and Foam, while file moves and renames are tracked in the body, thats not the case if you have an in your YAML. I find the id: concept genuinely useful. I dont use the !view function as I do not have enough files tracked to use it. I really appreciate your effort. If you intend to continue to support and update the extension, I am happy to set up a monthly donation. Let me know!

Collapse
 
javier_ramrez_e2b4bb54fb profile image
Javier Ramírez

Hi Jeremy!
Sorry for the response so late!
I've been really busy with work.
There's been some VS updates in the past couple of weeks that have made me adjust quite a bit so just in the past 3-4 days or so I've been really able to start polishing things and I see a real opportunity to harden and strengthen Yamlink moving forward.
It's currently in 0.4.0 release and now the focus is to stress test to see how far along we are in terms of massive vaults, query, and graph performance. Part of my delays in update is that I'm trying to understand how themes in vscode work to have Yamlink have its own light/dark theme, but that's down the road.
It is my intention to keep updating Yamlink as much as I can.
I really appreciate your support and I hope to update YL on a 15 day basis (fingers crossed!), but at the moment if you want to make any sort of donations, I guess you can do it on Paypal (link at the bottom), but really for now my main goal is to hopefully develop a community around this and together find bugs, look for improvements, etc.

Thank you so much for your kindness, though like I said, the main idea is to develop a community!
paypal.com/donate/?hosted_button_i...

Take care! Hope to hear from you soon!