The ever-evolving topic title. I like it. It’s definitely improved since your first confusing intervention. Let’s see how many more times we can change it.
I’ve seen this request evolve through different title, and today I wrote an answer to a similar request:
In your case, using publish, you do need to get the values as static text eventually, and as such the current option could be to use the Linter plugin and create a custom rule which update a static placeholder with the value from the frontmatter.
This is otherwise known as persisting the result of a query, but since you don’t want the code of the query to be shown in your published page I think your best option would be to create a QuickAdd macro doing this transformation to update the static placeholder.
Thank you, @holroy. You’re right, for the result to appear in Obsidian Publish correctly, the content needs to be straightforward markdown. It is possible to use plugins to generate the markdown. I’m not familiar with Linter but I guess it works in a similar way to the Meta Bind and DataView plugins.
I was hoping to find a simple way to automatically update a line in the body of the note to display “Last updated: [Date]”.
This is what I’ve learned:
- There is not a built-in solution that allows for frontmatter data to be displayed in the body of a note.
- It is possible to use community plugins to populate and automatically update “Date Created” and “Date Modified” fields in the frontmatter
- Plugins such as Meta Bind, Dataview (and maybe Linter) can display frontmatter data in the body of a note
- However, frontmatter data placed in the body of a note is not necessarily rendered using markdown and so will not be displayed by Obsidian Publish — only the code is displayed
- It’s possible, as you describe, to render the frontmatter as static markdown, which does display correctly in Publish but because it’s static, it won’t update automatically. It would be necessary to manually prompt an update to the modified date, for example.
In the absence of a way to easily place frontmatter data into the body of a note, by far the simplest solution is just to add the date manually when updating a note.
I do this without using any community plugins. I’ve simply created a template with the core Date field in a callout (the callout isn’t necessary, it’s just for formatting) and I pull that template in manually each time I update a note.
I’ve learned a lot as this query has evolved and I’m grateful to the people who’ve chipped in with hints and advice. If a future version of Obsidian allows for frontmatter data to be easily added to the body of a note, that would be splendid. Until then, I’ll carry on with the manual approach.
While Dataview, Templater and QuickAdd are most often used to insert either dynamic and/or static text, the plugin Linter is written to make your markdown adhere to predefined rules regarding syntax and structure.
As such it’s processing the notes on a different timing than the other, aka on file save, enabling the possibility to make a custom rule stating that the note should update this static placeholder according to the corresponding frontmatter value.
With such a rule in place, and a placeholder you could forget about updating the note even if you updated the frontmatter. So it would be a close to automatic as you could get it. The only thing you’d need to do is for each new note you need to place the wanted placeholder. (That is, after writing the script initially… )
I understand and can see how Linter would allow me to execute a script to update the body of a note with frontmatter data.
I think that’s probably more complicated (for me, at least) than the case justifies. Automating the note modification date automatically in a way that’s compatible with Obsidian Publish would be a “nice to have” and you’ve shown how that could be achieved, thank you.
I don’t have the knowledge to implement it easily but you have introduced me to Linter and I hope to get more familiar with it and with Javascript when time permits.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.