Option for static YAML from templates

Background

I am fastidious about ensuring that whatever I do in my Vault ensures that it is exportable in the event that Obsidian crashes and burns (or, you know, I decide I want to go elsewhere…heresy I know). To this end, I make use of plugins, that make my experience better (past URL, linter, recent files etc etc), but avoid anything that relies on proprietary code, that take away from the whole ethos behind using Markdown. I do occasionally use Dataview for finding notes, but typically just as a search bar on steroids.

Question

Is there a way to use templater to get metadata (file creation, title etc) and then insert as static text into my front matter, so that if and when I ever export the file, I don’t lose all my front matter? Templates can do this with {{date}} and {{title}}, but I have a many notes I would like to add this data to and this only outputs the current date and time, not pulls from metadata. I use dateModified and can live with that remaining as templater code, but would like the static variables to be as such.

Templates are dynamic, the metadata passed through them into markdown files become static.

If you talk about file system metadata pertaining to file creation and date modified, Linter can access those and print those to YAML.
Original title of note created outside of Obsidian in the past and have that automatically reflected in the metadata – I don’t think so.

My default template puts the title on top on file creation (this metadata is good for any app and will never be deprecated):

---
title: <%tp.file.title%>
foreignTitle: <% tp.system.prompt("Title is foreign [true/false]? [Press enter to set false]", false, false) %>
aliases:
  - <%tp.file.title.toLowerCase()%>
status: formatted
dg-publish: true
dg_upload: down
parent_topic:
  - <% tp.system.prompt("Want to define parent topic?") %>
date created: <%tp.date.now("YYYY-MM-DDTHH:mm")%>
date modified: <%tp.date.now("YYYY-MM-DDTHH:mm")%>
---

Which will yield for example:

---
title: BAK
foreignTitle: false
aliases:
  - Bak
  - bak
status: unformatted
tags: []
dg-publish: true
dg_upload: down
date created: 2022-12-14T00:00
date modified: 2024-02-21T13:45
  • Notice though date created (I just linted file to get these dates), which is not originally my date created, as it should be in the summer when I batch converted my files into txt. This date is due to some mass replacements because every date of my old stash is the same. (Lately, I’m using my own Python script for mass replacements and not use Notepad++ or any other app.)

Usually people like to stay on top of their own file created and modified dates and not rely on file system metadata. There are a couple of threads about this on the forum.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.