Obsidian Tips: Embedding Creation and Modification time in Front Matter of Notes
Updated: Oct 25th, 2023
By default, the Obsidian and others will not record the creation and modification time for notes. Instead, they rely on the file system of our laptop to track this information. However, this method has some drawbacks. I propose tracking the creation and modification time in the front matter of each note instead.
- If we change our laptop or copy notes to another location, we will
lose the time information.
- Since these metadata are stored at the file system level, copying a file creates new files.
- Consequently, the created time and modified time will be incorrect.
- Many blog systems (such as Jekyll) can read metadata from the front
- The default setup of jekyll blog
page.dateas creation time.
- https://github.com/maximevaillancourt/jekyll-last-modified-at can read
- When the creation and modification time are in front matter, you can use plugin like dataview to get the most recent modified note and achieve other useful features !
- Each time we store the node (or press
last_modified_atfields in the front matter should be updated.
created_atfield should reflect the creation time of this note.
- If the
created_atfield does not exist, automatic methods should read the creation time from the file system metadata and update this field in the front matter.
- When the
created_atfield already exists, automatic methods should not update it any further.
- If the
last_modified_atfield should reflect the most recent modification time.
- When we modify a note, this field should be updated accordingly.
- However, if we do not make any modifications to a note and simply
Ctrl+S, this field should remain unchanged.
- The format of time can be customized according to your needs.
TIPS: The name of field should fit your need. For example, many Jekyll plugins default to reading
page.datefor creation time. Since I use
page.created_at, some adjustments are necessary.
To achieve the goal, we will use the platers/obsidian-linter plugin, which is easy to use.
Once you configure this plugin as shown in the picture below, it will be ready.
My setup of time format is
yyyy-MM-DD HH:mm:ss Z