Display frontmatter values in body of notes on Obsidian Publish

What I’m trying to do

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.

1 Like

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!

I’ve changed the title to reflect what you seem to be asking. (Was “Adding frontmatter to notes”.)

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.

Is it Alan G’s plugin, right? (There is another with much the same name, I forget now. I use Alan’s one.)

In the settings, make sure you have this disabled:

Add your date modified property of your choice (modified, dateModified, date_modified, whatever):

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:

In the note I just made in the Sandbox vault:

You can use the Linter plugin to set order of property keys, so date_created is above date_modified, for example.

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.

I’ll reiterate my query with some additional screenshots.

I want to add a dynamic “Last Updated” field to the body of my notes.

Problem:

I can create a Frontmatter field using Alan Grainger’s “Update Modified Date” plugin, which populates and updates the date.

I can then use the Meta Bind plugin to add a view of the frontmatter date.

Meta Bind View instruction:

Meta Bind View result:

However, this result does not flow through to my Obsidian Publish website, where the Meta Bind view is not rendered in the same way as in my vault.

Obsidian Publish Page:
4 Publish

TL;DR
I want to insert frontmatter data into the body of a note and for that data to appear correctly formatted in my Obsidian Publish website.

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:

Created:: `$= dv.current().date_created`
Updated:: `$= dv.current().date_modified`
  • I use snake_case format frontmatter keys everywhere. Your format might be different.
1 Like

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.

I have tried both Meta Bind and Dataview approaches now, both with the same result.

In both cases I can insert the frontmatter data in to the body of a note.

Meta Bind and Dataview results:

However, in my Obsidian Publish site, only the source code is rendered, not the result that appears in my vault.

Obsidian Publish screenshot:
2 Publish

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".

This might be the blog post you saw?

Or something similar?

If you have access to change the title, that would be helpful, thank you.

“Adding Frontmatter to notes for Obsidian Publish” would be an accurate title to describe the query now that it’s evolved from my original question.

I think that’s the one, yes.

I’ll do it now, then.

1 Like

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 :grimacing:

1 Like

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.

Cheers!

OK, I’ve changed it back, but I don’t understand your difficulty (I see you’ve posted more below, so I’ll check that).

(Modified title was, “Adding Modified Date to notes on Obsidian Publish”.)

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.

The problem you encountered — Publish’s limited support for community plugins — is mentioned in the documentation: Publish limitations - Obsidian Help

There might be a feature request for this that you could upvote; if not, you could post one.