I’m curious why there isn’t a way to easily add frontmatter properties to a note.
I realise that I can add the Title and Date with template variables (see Templates - Obsidian Help) but that’s all. I wonder why it’s not possible to add other properties in the same way?
Things I have tried
I would like to be able to add other frontmatter properties, e.g. modification date, which can be automatically added to the frontmatter with the “Update frontmatter modified date” plugin.
But without the added complication of yet another plugin, there doesn’t seem to be a way to easily add frontmatter data into a note. If anybody has a simple solution, I’d love to know.
If you’ve got access to javascript you can call the app.FileManager.processFrontMatter() to modify the frontmatter. Examples have been given in these forums.
Thank you. I have taken a look at that but it seems like it might be unnecessarily complicated (for me, at least). All I’m trying to do is add a dynamic “Last modified: Date” to my notes. I was able to do this using the “Update modified date” and “Meta Bind” plugins but that result didn’t flow through to my Obsidian Publish pages.
It’s one of those things that seems like it ought to be really straightforward — automatically adding a date to published pages — and perhaps it’s possible with the Javascript you shared a link to but perhaps simply typing a date in manually is the route of least resistance!
That’s not quite correct. I am able to add the modified date to the frontmatter using the Update modified Date plugin. What I’m seeking to do is to add frontmatter data to notes, hence, “Adding Frontmatter to Notes”. The original title was accurate, the amended title is not.
Whatever property key you set, it will be added as a frontmatter key plus value (add in the settings what you want to use as date format; many people use YYYY-MM-DDTHH:mm because that’s what Dataview likes).
So if you have zero YAML frontmatter in the note, created and modified keys and values are added if you have these settings:
Thank you. I think this is an excellent answer for the question that appears in the moderator-amended title. Unfortunately, the title is misleading and I’m not sure if I can change it back to the original title, which was correct and did not require adjustment.
As I’ve explained above, I can use the Update Frontmatter Modified Date plugin by Alan Grainger to populate Date Created and Date Modified fields in the way you have described.
What I am trying to do is to insert that information into the body of a note.
It doesn’t have to be the date, it might be any frontmatter information.
I’m sorry that you’ve taken the time and trouble to provide a solution to the wrong question. Hopefully a moderator will change the title of my question back to the original so it’s no longer misleading.
That’s different.
And you would still need to install another plugin: Dataview.
And you would still need that plugin – Dataview – to extract the relevant information – from the frontmatter – data that you now have through Alan G’s plugin.
There is a thread on this:
But in your case, if you want to use your own properties, instead of the file system data Obsidian checks for, you’d use:
Thank you, Yurcee. Yes, it is different. Hence the original title of my query, which was “Adding Frontmatter to Notes”, before a moderator altered it.
Hopefully, my last post explains what I’m trying to do and what I’ve been able to achieve and the screenshots will help. I have now found a way to insert the frontmatter into the body of a note, in the same way as you describe using Dataview.
The last step would be to get this result to appear in my Obsidian Publish website in the correct format.
I will try the Dataview approach and see if that’s the answer. Thanks for taking the time to reply.
In the past I saw a blog where the person applied some hack to make Dataview work on Publish. I can’t find it now.
You can try and find it on this forum (search with dataview publish).
About the title of your choice, would you want me to change it?
I can modify it to something like `Working with Date Modified frontmatter metadata to add to Obsidian Publish site".
Josh Plunkett also has a helpful YouTube tutorial explaining how to render Dataview results as Markdown suitable for Obsidian Publish:
So by installing the ‘Update modified date’ plugin, the ‘DataView’ plugin and the ‘Templater’ plugin and then following the instructions in Josh’s tutorial, it would be possible to automatically add a ‘Last Updated’ or ‘Last Modified’ date to an Obsidian Publish page.
Or, you know, you could just type the date in manually and resist the temptation to over-engineer a solution
I don’t use Publish, so you are welcome to experiment.
One final thought though: you were right to assume you’d need a frontmatter value, because once you’re out of the Obsidian app, file.mtime might not work at all.
You’re absolutely correct. Publish only renders Markdown so the native DataView output won’t display as it does in the Obsidian app.
Anyway, I’m really grateful for your time and suggestions. You’ve helped me find a (sort of) solution. Hopefully a future release might include a way of adding Frontmatter data to the body of a note as markdown without all the additional steps.
Your original title (and post) does not make clear that you want to display frontmatter values in the body of a note. When you say “adding front matter to a note”, people will understand it to mean adding the frontmatter section, or adding values to it, not using those values in the body of a note.
I’m changing the title again to make those things clear.