Adding dates and times to all new notes

Newish user here still finding my feet, so apologies if this is a stupid question! I’ve searched and can’t find a clear answer.

I want to ensure that every new note has a few lines of metadata at the top, such as the date and time the note was created. I would like this to appear with brackets so it links back to my daily note for that day, so I can see which notes were created on each day.

I know how to do this with a template, so if I create a new note, template appears and this is fine.

However, lets say I’m typing a note on a topic, such as sports. I want to link out of sports to [[cricket]], but I leave the [[cricket]] link unclicked for completion tomorrow. Is there a way that when I click on [[cricket]] tomorrow, that note is created with the appropriate metadata, including the date, already included, without me having to manually run a template?

I’m sure this is easy, and I’m doing something wrong, so grateful for any guidance.

You can try the Templater plugin. It allows for templates to be resolved at file creation.

Templater can also place templates into empty files when created within a given folder.

Quick question: do you want the Cricket note to have the date for when the link was created? Or for when you actually created the note?

I use templates for this. I have yaml at the top of the template that looks like this:

---
alias: []
tags: [reference]
created: {{date}}
update: 
---
# {{title}}

I only include the date, but you can easily add the time if you want.

Thanks for replying.

I want it to be the date I finally create the note, having clicked on the link. For example, I write the note [[sport]] on the Saturday. Within the [[sport]] note I include the link for [[cricket]], but it doesn’t yet exist. But I click on [[cricket]] on Sunday. I would want the date to be the Sunday.

I hope that makes sense.

Thanks again.

Thanks for the response.

In this example, what would your “alias” be? Just interested.

I find it most useful in my People notes. I have a note for all the important people in my life, family members, friends, colleagues, etc. So a person’s formal name might be “Michael Smith”, but everyone calls him Mike. I will always use the full name for the Note, but add “Mike” to the alias. This way you can use the alias when creating links and Obsidian will find the “Michael Smith” note.

Amazing. Thanks

If you want the date the note is created, add {{date}} to your note template, and it will replace that text with the date you create the note.