How to add Frontmatter to already existing notes

I have quite a few markdown files (~800) and wanted to add frontmatter to them. Is there any way where I can automatically add some file attributes like filename, created time, updated date in the frontmatter ?

Going forward if I where to use frontmatter in all the notes I create is there a way to have it automatically added ? How would I have the file updated time attribute show the current value always ?

Are there any attributes that are commonly used and recommended which would make finding/ queering my files easier.

1 Like

Why would you want to add this dynamic information, readily available to you using Dataview, as static information into each file?

If you really want it, templates can insert whatever text you want into a file on creation. They will not show the updated time, only at insertion time.

For dynamic display of this information, you could use Dataview, (possibly inserted originally by a template :smile: ).

Which attributes to add, kind of depends on how you are planning to view the files, and/or search/query the files. This largely depend on personal preferences, but I do see that both tagging and folders (and links) can be used to provide various grouping options, which are then used when you query/search your files.

To basically it comes down to what is your use case, and what information do you need to be present in the various files? I for one, wouldn’t bother to include information which is readily available through tools like Dataview into the file itself.

Well I plan to at some point in time convert the markdown files into a static site and for that was trying to find a way to mass add some basic attributes.

Doesn’t Dataview also require frontmatter information to be able to query the files ?

As can be seen here: Metadata on Pages - Dataview, loads of the data are implicitly given, in addition to those you specify in the file somehow (also described on that page).

It do still seem like you should read up on what plugins like Templater can do for you in terms of inserting static stuff, and in addition to what Dataview can do for presenting dynamic information. Those two in combination should get you going, I think.

I will check them out.

So there is no way to add frontmatter to the files that already exist ?

There is. You can still use ordinary editing, and/or templates, but it is a slightly different way when using templates.

And how would I do that ?