Frontmatter date and file name is not working

What I’m trying to do

Hi All , I tried to use front matter in my template so that it will have tags , filename, creation date and modified date. but only the tags and alias in my YAML frontmatter is rendering.


title: <%= tp.file.title %>
aliases:
created: <%= tp.file.creation_date(“dddd, MMMM Do YYYY”) %>
modified: <%= tp.file.last_modified_date(“dddd, MMMM Do YYYY”) %>
tags: [DailyNote]

Output

Things I have tried

I tried multiple pulgins like data view and templatr but nothing could help . Please help resolve this.

It looks like you’re using the Templater plugin commands improperly.

First and foremost, commands should look like this <% tp.file.title %> without the =.

Some things to make sure you’ve done first:

  1. Download and ‘Enable’ the Templater community plugin
  2. Read the Templater community plugin documentation

Here’s a link to that documentation in case you haven’t read it over yet: Introduction - Templater

1 Like

Thank you very much!!. It is correct that I haven’t done the configuration properly in my templatr plugin. Just eanted to know one more thing , is there a way to make the same YAML to work without that plugin I just needed it for the creation and modification date. It would be nice without the plugin . Is that possible?

There exists an alternative to the community plugin Templater (with “r”).

The core plugin Templates (with “s”) is part of plain vanilla Obsidian: https://help.obsidian.md/Plugins/Templates

It works well for my daily notes. Your template could look like this:

---
title: {{date:YYYY-MM-DD}}
aliases: 
created: {{date:YYYY-MM-DD HH:mm:ss}}
modified: {{date:YYYY-MM-DD HH:mm:ss}}
tags:
  - DailyNote
---

Make sure that you edit the template in Source Mode. Otherwise the date templates might not work as intended.

1 Like

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