# Obsidian Publish with Dataview
![[images/Obsidian-Publish-with-Dataview.webp]]
[Watch on YouTube](https://www.youtube.com/watch?v=c440B2aOPJ8) · 22:45 · Josh Plunkett · 2023-09-09
> Written from the video's full English captions, with chapter times from the description. The method comes from [Joschua.io's tutorial](https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/); Josh's own code examples are on his [Dataview - Obsidian Publish page](https://obsidianttrpgtutorials.com/Obsidian+TTRPG+Tutorials/Plugin+Tutorials/Community+Plugins/Dataview/Dataview+-+Obsidian+Publish). Josh later covered a dedicated plugin for this in [[Obsidian - Dataview Publish Plugin]].
## Outline
### 00:00 Intro: Publish doesn't run plugins
- Today's topic is **Dataview and Obsidian Publish** working together. Anyone who has used Publish for a while knows it **doesn't support plugins**, which is a problem because so many people rely on Dataview.
- His example is a **Dataview query** rather than a hand-made table: show a table of character name, player, class, race, level and role from his party folder, where the role is Player and the status is Active.
- In the vault that gives a live list of his player notes with some basic stats. Add a new player and the table updates itself; mark a player inactive and they drop off automatically.
![[images/Obsidian-Publish-with-Dataview-t0115.webp]]
*The live Dataview table in his vault on the "Dataview - Obsidian Publish" note: character name, player, class, race, level and role for the active players.*
- On the published site, though, you just get the query text in red code formatting. That means nothing to a visitor, who wants the information, not the query.
![[images/Obsidian-Publish-with-Dataview-t0135.webp]]
*The same note on his Obsidian Publish site: the query (TABLE WITHOUT ID … where (Role = "Player") where (Status = "Active")) appears as raw text instead of a table.*
- The goal of the video is to make the actual table appear on the published site when you publish.
### 01:44 Joschua.io
- Credit where it's due: "definitely not my idea." **Joschua** at joschua.io created the template and the tutorial. His blog covers how he takes notes and works, with some fairly advanced topics; it isn't TTRPG-related.
- The tutorial is linked in the description and Josh recommends reading it before following along. He then shows how he used it for his own published site.
### 02:40 Required Plugins
- **Dataview** by Michael Brenan: if you're looking to publish Dataview queries you probably have it already. Install and enable it.
- **Templater** by SilentVoid: install and enable it too.
- While you're in settings, **check the hotkeys**. His "Templater: Open insert template modal" is **Alt+E**, which matters because that's how he triggers his publish.
- Also note Templater's **template folder location**, since that's where the new template goes. Both settings may differ in your vault.
- He shows where this already works: the front page of obsidianttrpgtutorials.com has **Recently Added** and **Recently Edited** lists on the right. They're not queries on that page. He uses the **ITS Theme** to make a wiki-style info box, and the box just embeds links to two separate notes.
- Those notes contain no Dataview queries at all, only **markdown tables**. The template runs the query, converts the results to markdown, and writes them into the note in one step. The note is overwritten every time the template runs, which is why the results live in their own note rather than inside the page's main content.
- The **exclamation mark** before the link is what says "render this note inside this note." Without it you'd just get a link. Publish then simply publishes those files.
### 06:23 Example
- In his templates folder he has an **Update Publish Files** template. It's a fairly complex piece of code that he doesn't pretend to fully understand, but as he understands it, Dataview has an **API** that lets the template pull query results and map them into markdown.
- You can ignore most of the code. The part that matters is a list of pairs (the green section): each pair is a **note name** and a **Dataview query**.
![[images/Obsidian-Publish-with-Dataview-t0740.webp]]
*His Update Publish Files template: it loads the Dataview API and the "publish:view-changes" command, then a list of note names and queries (Recently edited, Player List, Recent new files), each a TABLE WITHOUT ID query; below it, a loop creates any missing note with tp.file.create_new and shows a "Created" notice.*
- Copying one pair into Notepad: "Recently edited" is the note it will write. It can be a new or an existing note, but an existing note will be **overwritten**, so he suggests using a new name.
- The query part is ordinary Dataview: a table without ID, the file link renamed to Note, a Modified column, plus FROM, WHERE and SORT clauses. Any query you already use can go in here.
### 08:50 Dataview Query Builder
- A reminder that his **basic Dataview Query Builder** exists, a step-by-step wizard for building queries. It's under Plugin Tutorials, in the Dataview and Other Advanced Plugins section of his site, alongside **Dataview Examples** (for example, listing recently modified locations, with instructions and an explanation of how each works). He keeps adding to that page.
- His workflow: paste the query into a live note first and confirm it works, then copy it into the template.
- His template has two pairs already, creating **Recently Edited** and **Recent New Files**. A further section adds a comment line to those files, so you can write other content into the note too, and there's some error handling.
- To add his player table, he copies the working query and adds a new entry following the exact syntax: an opening square bracket, the note name (**Player List**, indented to match) in quotes with a comma, then the query in quotes. He removes the line breaks so the query sits on one line like the others, and closes it with a quote, a comma and a closing bracket.
- He did modify Joschua's original template, which added some extra text he didn't need. He just wanted raw tables he could pull into other notes.
### 13:46 Publish
- From now on, the **Publish changes** button is "effectively useless" to him: to refresh the queries, he publishes through the template instead.
- He presses **Alt+E**, types "publish", and runs Update Publish Files. Notices show the notes being updated and created, and the Publish dialog opens.
- On the first run, the new **Player List** note was created in his templates folder, which his published site can't see, so he dragged it to his player list area. After that it's regenerated wherever it now lives.
- In edit mode the note holds a **markdown table**, not a Dataview table, and the escaping is handled automatically.
![[images/Obsidian-Publish-with-Dataview-t1545.webp]]
*The generated Player List note in his vault: a plain markdown table of the active players, sitting under his Obsidian TTRPG Tutorials folder.*
- Running it again updates three notes, then the Publish dialog picks up that Recently Edited has changed. He backs out to tick the new Player List file (and clicks "add links," which he always does to check everything is connected), then publishes. On the site, Player List is now a working table with live links.
![[images/Obsidian-Publish-with-Dataview-t1650.webp]]
*His published Obsidian TTRPG Tutorials front page, with the Recently Added box on the right listing new tutorials and their dates, generated by the same template.*
- Other Dataview queries in his sub-notes still don't render. **Every query needs its own entry in the template and its own note.**
- Queries that depend on the current note, like `this.file.name` or `this.property`, probably won't work well with this approach, because the results are written into a separate note.
- To show the table on the Dataview - Obsidian Publish page, he doesn't write into that page directly: the template rewrites whole notes, so he'd have to code the entire page into it. Instead he embeds the generated note with an exclamation mark and double square brackets (`![[Player List]]`). The embedded version looks a little different from a native Dataview table.
- He deletes the original live query, runs Alt+E and Update Publish Files again, publishes, and the table now appears at the bottom of that page on the site. It still links through, with a black box around the embed.
- He hasn't tried coding a table into an existing note, which he understands takes more work. A separate note is easy to rewrite and can't damage your other notes.
- The payoff: visitors can see his newest and recently edited tutorials. For example, that morning he'd updated the Pathfinder and 5e pages with the new Foundry export process, and it showed up as edited.
- The recipe: create one entry for every query you want on the site, publish it as a separate note, and pull it into the page with an exclamation-mark link.
### 20:33 Outro
- "Huge hats off to Joschua.io" for solving a long-standing problem: everyone uses Dataview and wanted it on their sites.
- He calls on Obsidian to support this natively in Publish, since "we're all using it."
- His site will link to the original tutorial and to his own queries so you can see what he changed.
- Thanks to his Patreon supporters. For help, go to obsidianttrpgtutorials.com, check the **Community** tab at the top and join the **Discord**, where many of the plugin developers also hang out ("more of us dice rollers hanging out in that Discord than any other place").
## Things mentioned
### Obsidian plugins, themes and features
- **Dataview** by Michael Brenan: runs queries over your notes and their properties; its API is what the template uses to turn results into markdown (**free**)
- **Templater** by SilentVoid: runs the Update Publish Files template; "Open insert template modal" bound to Alt+E; set the template folder location (**free**). See [[Obsidian - Templater]].
- **Update Publish Files** template: Joschua.io's template, trimmed by Josh, that writes each query's results to a named note and opens Publish changes (**free**, from the tutorial)
- [Obsidian Publish](https://obsidian.md/publish): hosts his website; doesn't run plugins, so Dataview queries show as raw text (**paid**)
- **Embeds** (an exclamation mark before a `[[link]]`): render one note inside another
- **ITS Theme**: used for the wiki-style info box on his front page (**free**). See [[Obsidian - ITS Theme]].
- Later alternative: [[Obsidian - Dataview Publish Plugin]]
- Related notes: [[Obsidian - Getting Started with Dataview]], [[Obsidian - My New Tab Screen (Dataview Examples)]], [[Obsidian Publish - How to publish content to a website]]
### Websites, tools and guides
- [Joschua.io tutorial: Obsidian Publish with Dataview](https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/) (**free**), the original method
- [Josh's Dataview - Obsidian Publish page](https://obsidianttrpgtutorials.com/Obsidian+TTRPG+Tutorials/Plugin+Tutorials/Community+Plugins/Dataview/Dataview+-+Obsidian+Publish), with all of the code shown (**free**)
- **Dataview Query Builder** and **Dataview Examples** on obsidianttrpgtutorials.com, under Plugin Tutorials in the Dataview and Other Advanced Plugins section (**free**)
- [Obsidian TTRPG Tutorials](https://obsidianttrpgtutorials.com), with its Recently Added and Recently Edited lists (**free**)
- **Notepad**: used to look at a query pair outside Obsidian
- [Obsidian](https://obsidian.md/) (**free** core app)
- [Official Obsidian Discord](https://discord.com/invite/veuWUTm) and the Obsidian TTRPG Community Discord (**free**)
- [Obsidian TTRPG users Facebook group](https://www.facebook.com/groups/obsidianttrpgusers) (**free**)
- Josh's Patreon (**paid**, optional)
### TTRPG context
- His **party notes**: a player table with character name, player, class, race, level and role, filtered to active players
- **Pathfinder** and **D&D 5e** tutorial pages he'd just updated with the new **Foundry VTT** export process
### Free vs paid (quick)
- Free: Obsidian core, Dataview, Templater, the template and tutorial, ITS Theme, his tutorial site, the Discords and Facebook group
- Paid: Obsidian Publish, optional Patreon
## Bios
- **Josh Plunkett**: Australian GM and educator behind Obsidian TTRPG Tutorials (YouTube and obsidianttrpgtutorials.com). He publishes his tutorial site with Obsidian Publish and uses Dataview heavily, here to automate its Recently Added and Recently Edited lists.
- **Joschua (joschua.io)**: Blogger who writes about note-taking and his own workflows, including advanced Obsidian topics. He worked out and shared the Templater-based method for getting Dataview results onto an Obsidian Publish site that this video follows.
- **Michael Brenan**: Developer of the **Dataview** community plugin, whose API makes this method possible.
- **SilentVoid**: Developer of the **Templater** community plugin, which runs the publish template.