Inserting templates in the YAML section doesn't work in v1.4.5

Steps to reproduce

  1. placed the cursor in the YAML value field.
  2. CTRL-T to open templates selection window.
  3. selected the template that contains: {{date}}; {{date:YYYY-MM-DD-HHmm}}.

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

Friday, September 1, 2023 10:14 AM; 2023-09-01-1014.

Actual result

Nothing displayed anywhere.

Environment

SYSTEM INFO:
Obsidian version: v1.4.5
Installer version: v1.4.5
Operating system: Windows 10 Pro 10.0.22621
Login status: not logged in
Insider build toggle: off
Live preview: off
Legacy editor: off
Base theme: light
Community theme: Blue Topaz v2023080203
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.


Additional information

Prior to this morning, before the new 1.4.5 automatically installed, I regularly inserted {{date}} commands in the YAML section using templates. Now, those templates don’t work.

Examples of three different templates I manually inserted when needed:

{{date}}

{{date:YYYY-MM-DD-HHmm}}

{{date}}; {{date:YYYY-MM-DD-HHmm}}.

The YAML headers that contain the {{date}} commands still work fine when a new note is created. New note header template example:


Aliases:
FirstCreated:

  • {{date}}.
    Dates Modified:
  • {{date}}; {{date:YYYY-MM-DD-HHmm}}.

As a work around, which I hope is temporary, I insert the template in the note body, then copy and paste the result into the YAML.

The other process that seems to work, but seems like it could lead to problems, is using CTRL-Z after inserting the {{date}}. When the {{date}} template is inserted in the YAML nothing happens. Immediately using CTRL-Z the date displays.

I hope there’s something I need to change in the settings to fix this issue.

I’m also hoping this isn’t the new reality with the introduction of the “Properties” feature.

Thanks in advance for any help.

5 Likes

I am experiencing the same issue.

Many of my notes were created using templates and automatically-generated frontmatter using the {{date}} and {{time}} variables.

After updating to version 1.4.5 today, the templates no longer import YAML frontmatter at all.

I do notice that the YAML frontmatter section in the template file is now highlighted red in the default UI:
image

When I select this file to be imported as a template, it skips over all the frontmatter so that it is absent in the newly-created file.

My installer version was out of date (something like 1.3.7) so I re-installed obsidian.
This fixed the issue where the YAML Frontmatter wasn’t converting to the new Properties feature.
So all my old notes have been correctly converted to use properties.

My Current Workaround
In order to get the templates to work correctly, I had to manually create a property for each line of the YAML in the template.
In order to get the {{date}} and {{time}} variables to trigger correctly, I had to follow a specific set of steps:

  • I created the property and named it
  • Change the property type to plaintext
  • insert my {{date}} and {{time}} variables
  • change the property type back to date or datetime (whichever is applicable)
  • ignore the warning which pops up to tell you that the property is incorrectly formatted

When I then create a file using this template, it populates correctly. Hopefully this workaround will work for you!

When you revise or modify your meeting content, how does the updated field in the YAML frontmatter get populated with the modified/updated date and time?

@mymemory, I use a plugin called Linter which I’ve configured to automatically update the date/time in the ‘updated’ field.
Luckily it is currently working well with properties.

I think i have a familiar problem with updating aliases. Perhaps this helps for bugfixing.
I’m sorry but i cant take some time to test if my problem is a bug or not → So i just went for the help request.

I am not sure I understand the bug report here.

You need to make sure that YAML in the target note and the YAML generated by template are valid. Otherwise, no merge is possible.

You need to attach here a copy of the template that you are using and a copy of the file that you are applying it to.

Please make sure you are using the core template plugin and not any third party plugins.

I started using Obsidian in January 2021 and there are currently 54,948 notes in my vault. So far, I’ve inserted a YAML frontmatter section in 7,401 of them.

I’ve experimented with plugins, but I haven’t found any that will work for my notes. I maintain a revision history for each note. After each revision a PDF is generated for that note. I use the revision date, rather than v1, v2, v3, etc. as one of the several elements in the Filename. I use a CSS snippet that someone developed so that the YAML section prints on the PDF. Refer to: Frontmatter is not visible when printing - Bug graveyard - Obsidian Forum The CSS snippet that works for me, which was included in the discussion, is found at: You don’t like the way Obsidian shows frontmatter in V1.1? Here’s how to fix it in three easy steps | by Zachary Shirmohammadli | Medium

I’m going to try inserting snippets because I don’t know any other way to attach a copy of the templates. I’m also hoping a snippet of my PDF filename elements will help you understand why my YAML frontmatter template requires additional “inserted” mini-templates.

The following is one of my YAML section templates:
image

The following is one of the “mini-templates” I insert in the “Dates Read” field:
image
I use CTRL-Z after inserting this so that it populates the field.

The following is a MS PowerPoint document image. I use it to keep me consistent on my PDF filenames:

It doesn’t look like your templates generate a valid yaml, so they are not gonna work.

WhiteNoise, thanks for your time in trying to help. Before v.1.4.5, the yaml templates I used worked, so I’m not sure what part of them isn’t valid.

I click on the “Create new unique note” icon in the left-side pane. This inserts the ISO 8601 as the filename. Then I use CTRL-T to select one of the many templates to populate the note, which includes the “master YAML section”. I then manually insert data in the YAML frontmatter section if one of the “mini-templates” doesn’t work. I’ve experimented with several plugins, all of which were able to read what was in the yaml frontmatter. So, I’m not sure what is invalid about them.

I didn’t know anything about YAML before Obsidian introduced the amazing “aliases” feature. The bulk of my notes contain invalid characters which aren’t allowed in a Windows filename. The aliases feature allows all the characters in a title I’ll ever need. Prior to that, I inserted the correct title and all the multiple dates in the appendix section of each note.

You didn’t mention if using CTRL-Z was going to cause problems. So, I guess I’ll have to keep typing the two additional keystrokes to produce the results I was used to seeing in the prior to v1.4.5.

I’ve used multiple PKM programs in the past, like TreePadX, ConnectedText, OneNote, etc. Obsidian is by far the best! Thanks for all your hard work in bringing Obsidian to the masses!

I found the solution for my problem:
Untill now I used the external extension “Templater v1.16.0” and with this the aliases didn’merge after inserting the template.
Today i tried the core extension and the mere of aliases works. So i will only use the core extension and im happy with the result.

Thank you all for your input and help to find that solution - Obsidian support and community is very very helpful. Thank you so much!

I have a slightly different problem but falls under the same heading so adding to this discussion instead of starting a new one - I hope that is OK, happy to start a new thread if necessary!

Previous workflow:
When I create a new note, I have been using Tempalates plugin to insert a template that uses Templater formatting to automatically populate the frontmatter with a number of fields including date created, last modified date, a unique ID, etc.

For example, for note titled “YYYYMMDDHHmm Experiment test”, I would insert:
ID: <% tp.file.title.split(" ")[0] %>
Date_created: <% tp.file.creation_date(“DD MM YYYY”) %>

Expected result:
ID: YYYYMMDDHHmm
Date_created: 18 09 2023

Actual result (reading view):
ID: <% tp.file.title.split(" ")[0] %>
Date_created: <% tp.file.creation_date(“DD MM YYYY”) %>

Problem:
As far as I can tell, Templater formatting is no longer working in frontmatter at all, in any Property “type” (text, date, list etc). I’ve tried using different formatting (eg: {{date}} ) but I can’t get that to work either.

Current workaround:
I’ve switched to using Linter to add created and modified dates to YAML, which is working fine.

For other fields such as ID, my best (only?!) idea is to edit my template to insert these fields inline at the start of my note instead of in frontmatter. This means that I can still create and populate these fields automatically - I often want to create a note quickly and don’t want to (read: realistically will never make myself) do it all manually. I mostly use these fields with Dataview, and Dataview can access them inline.

Questions:

  • Am I correct that it’s not possible to automatically populate Properties using dynamic commands or template variables? Or does anyone know how to do it?
  • Dataview can read inline fields so I can use my workaround for future notes without changing my workflow too much. But, how much should I worry about having this information inline instead of actually in the frontmatter? I have to admit I don’t really understand the difference between these two situations (in YAML or inline), only that Dataview can access the information either way.

I love the concept of Properties but at the moment it is really stuffing up my workflow (to say nothing of my existing notes).

1 Like

It still works from my side of the screen :thinking: … as long as you apply the template through Templater and not through the Obsidian Template core plugin (as the syntaxes used by both plugins are incompatible)

Example: Here’s a Templater template that works for me for a file named : 202309191433 Experiment test :

<%"---"%>
idText: '<% tp.file.title.split(" ")[0] %>'
idNumb: <% tp.file.title.split(" ")[0] %>
created: <% tp.file.creation_date("YYYY-MM-DD") %>
<%"---"%>
# This is a Templater test
<% tp.file.cursor() %>

Templater test

Regarding Templater Dynamic commands (<%+ ... %>), I’ve never used them though…

I have related problems, as well. I believe they largely are plugin-related, so there’s that. But anything I was using before that created a note from a template now just ignores everything that’s supposed to be part of the front matter.

It means that my entire workflow now has to be redesigned, and thousands of notes currently don’t display information I could readily reference before without my having to poke around in menus and jump through hoops.

This is really disappointing for software that emphasizes the importance of future-proofing. PLEASE, guys, don’t become like other apps & platforms that get all feature-happy and lose sight of the core purpose.

2 Likes

Thank you! Yes, switching to a Templater template works.

Dynamic commands don’t work but the main field I want this for is “date_modified” and I can use Linter for that.

But, like @a2jc4life, I still have a bunch of existing notes where the frontmatter is totally messed up. (I am ignoring the actual number right now, I’d prefer not to know!!) Although I think Properties is a great feature, for those of us with incompatible existing workflows it would be great to be able to disable it properly (not just change the view).

2 Likes