Template(r) code to link back to Daily Note using date in file title

I have Daily Notes with filenames in “YYYY-MM-DD” format and Meeting Notes with the filename format “YYYY-MM-DD - Project A Status Call”. Most meeting notes will be initiated by clicking on a link from a prepared list of the day’s meetings that I manually insert into the Daily Note the night before or in the morning. I often transcribe Meeting Notes from a recording days after the actual meeting rather than clicking the link and taking notes during the meeting.

The Meeting Notes are formatted with a Templater template. Based on my workflow, Meeting notes will have a linked mention back to the Daily note, but I would like each Meeting note to be pre-populated with a direct link back to the Daily Note for that day based on the date in the filename since the current date may be different from the day the meeting occurred.

Is it possible to parse the date’s filename and add it as a simple [[YYYY-MM-DD]] link back to the body of the note in a template? Would you recommend another workflow?

This is my current Meeting Notes Template

up:: [[Daily Notes Hub]]
tags:: #meeting
summary::

Attendees

Notes

<% await tp.file.move(“Calendar/Meetings/” + tp.file.title) %>

I just changed my workflow for meeting notes to include a link to the daily note last week, so this is great timing!

In my template, I used this syntax:
Date: [[<% fileDate = moment(tp.file.title, 'YYYY-MM-DD').format('YYYY-MM-DD') %>]]

Notes:

  • The brackets will disappear in the template when they are not highlighted, but they do need to be there to create the link to the daily note.
  • This doesn’t work if the note is not already named upon creation (i.e. if you do new note from template and apply this template, it will throw an error because there is no file name to draw the date from. I think you can fix this with the await command but I’ve never messed with that).

I hope this works for you! I’m far from an expert but it works for me.

1 Like

Thank you! That works great. Here is an example of the await command I used previously, which asks for a meeting name if there isn’t one.

<%*
let today = tp.date.now(“YYYY-MM-DD”)
let title = tp.file.title
if (title.startsWith(“Untitled”)) {
title = await tp.system.prompt(“Name of Meeting”);
}
fileName = title
await tp.file.rename(fileName)
-%>

1 Like

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