Old metadata {{date}} broke on daily note template edit

What I’m trying to do

I attempted to add a full date field to my daily template metadata for future notes, but updating this broke my previously working metadata. This was added before the metadata → properties update.

Here is this working on an older note:
Here is the updated daily note template, after I added the new date property:
As you can see, it broke my old properties when I added a new one. For some reason, aliases were unaffected.

Here’s the git diff that occurred:

I’ve tried to update this, but I must be missing something.
Editing the file manually and adding these like so:

This results in strange behavior inside of obsidian…

I’m not certain if this is a bug, or I’m simply using properties in a way that metadata supported, but wasn’t necessarily intended.

Looking at the screenshots I see that there is a big mess between properties type and their actual value. Numbers are added as strings (with the quotation marks). Date is added as string.

Your template must produce valid YAML and the YAML produced needs also to be consistent with the property types you choose in Obsidian.

How do I set property types?

This YAML was created and formatted before the update that, turning them into properties.

If I’m wanting to use dates with specific formatting, what type of property should that be? It’s not really a number, so I would expect a string to work with any kind of property

1 Like

I believe I’ve found the root of my issue. The daily note that I am using as a template must have the properties not set, so that they show the “?” on the icon. {{date}} formatting breaks regardless of the property I try to add with the “Add property” button. I also cannot change the existing property types on my daily note. Updating the property type on today’s note has them showing up without any type warnings from Obsidian for today and other dates.

As you can see:

Unfortunately, the problem of “Add property” not working remains. If I use this on today’s note, it only adds a property for today, not other daily notes.

Another example, I click “Add property” on my daily template:

Which causes the issue I mentioned above:

Raw markdown before:

tags: daily, dailies
alias: "{{date:MMMM Do YYYY}}"
iso-week: {{date:W}}
week: {{date:w}}
year: {{date:YYYY}}
day-of-year: {{date:DDDD}}
date: {{date:YYYY-MM-DD}}

Raw markdown after adding a property with “Add Property”:

  - daily
  - dailies
  - "{{date:MMMM Do YYYY}}"
  "{ date:W }": 
  "{ date:w }": 
  "{ date:YYYY }": 
  "{ date:DDDD }": 
  "{ date:YYYY-MM-DD }": 
people: test

Is this clear? I believe this is a significant issue, as I’m not able to add properties within Obsidian, having to resort to editing the raw markdown. Nor do I know what property type is proper for a formatted {{date}} in the daily template. I’m not only unable to change the property types, but adding a new property breaks existing ones.

You need to edit the template in source mode.

When dealing with templates you can’t use the ordinary methods to edit them. So Add property will in most cases not work, as it is intended for the final notes after the template has been applied. In addition using the properties UI might cause other unwanted changes to the properties of a template file. Therefore, please do use source mode when changing a template.

And when a template is applied to generate a note, that note don’t know which template was used to create it, so you can’t change the template later on and expect for all notes created with that template to follow suit (and have the changes applied to them). Changes to a template will only affect new notes created with that template.

I guess this is the solution, “don’t do it that way.”

If I’m not supposed to do something a certain way, and doing it that way has unintended consequences, shouldn’t that be a bug? I would expect Obsidian to safeguard me against such things that cause confusion. I realize Obsidian may cater to a more technical crowd, yet if you’re using the Live Preview mode to edit notes, you need to toggle regular Source Mode in the command palette. The only way you’d know that you needed to do that would be if you spent some time messing with it, or stumbled upon this thread.

It’s a complex problem to solve outside of telling users to not use the button, since Obsidian doesn’t have a way to know what file may be used as a template… In any case, I am happy there is a workaround.

this will be improved in the future.

1 Like

Thanks for your help, and I hope I didn’t come off as being snarky. I appreciate you and the work the Obsidian team does.

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