Invalid YAML in Frontmatter

I currently have this frontmatter YAML:

Aliases: [""]
Created on:{{date:YYYY-MM-DD}}-{{time:HH:mm:ss}}
Tags:
Source:
See Also:
Comments:

And I have started to get invalid YAML notifications. I’ve racked my brain (and eyes) and just am not seeing the problem.

Any and all help gratefully appreciated.

Thank you!

What I’m trying to do

If I remove this - {{date:YYYY-MM-DD}}-{{time:HH:mm:ss}} then the messages goes away.

However this was all working fine so far.

Mystified… :slight_smile:

Maybe you’re missing a space between the colon and the opening curly bracket

Created on: {{date:YYYY-MM-DD}}-{{time:HH:mm:ss}}

Thanks, Andre. That did not change the error.

Are you using a plugin for the “Created on” date?

Also, this works for me.


Created on: {date:YYYY-MM-DD - time:HH:mm:ss} 
Tags:
Source:
See Also:

It’s simply invalid YAML, check using the YAML Online Parser.

The

Created on:{{date:YYYY-MM-DD}}-{{time:HH:mm:ss}}

looks like a long key to YAML, and if you used

Created on: {{date:YYYY-MM-DD}}-{{time:HH:mm:ss}}

(with a blank after “Created on:”), it would still be invalid YAML, since colons are special.

You probably want to try something like

Aliases: [""]
Created on: "{{date:YYYY-MM-DD}}-{{time:HH:mm:ss}}"
Tags:
Source:
See Also:
Comments:

(use a blank after Created on: and use apostropes (") around the date/time string part).


Since the above is Obsidian Template code (have you switched on Settings → Core plugins → Templates?), you can also just use a blank after “Created on:” and expand the template first.

Both

Created on: 2021-07-22-08:40:13

and

Created on: "2021-07-22-08:40:13"

yield the same string in YAML.

1 Like

Thank you, Moonbase.

It turns out that deleting the space between Create On: and first curly brace and then adding it back solved the problem and notes now do not prompt the invalid YAML comment. I wonder if some control character had somehow entered there. Whatever it was, it is resolved!

Cheers!

1 Like