Templater in links

What I’m trying to do

Create dynamic links to other notes based on the file name of the note.

Things I have tried

This is what I’ve been trying to get to work:

[[The Lab/Weekly/<%+moment(tp.file.title).format("MMMM")%>/<%+moment(tp.file.title).subtract(1,'week').format("gggg-[W]ww")%>|<-- Previous Week]]

The individual pieces work outside of the link and render the correct string. I’m not sure why they don’t work inside the link.

I would appreciate any pointers!

I’m also not sure why, but they don’t seem to work without the + right after the %. Maybe that is related? With the + the code doesn’t render to anything and just displays as text.

I tried it on my machine. I couldn’t get it to work WITH the + signs. If I used [[The Lab/Weekly/<%moment(tp.file.title).format("MMMM")%>/<%moment(tp.file.title).subtract(1,'week').format("gggg-[W]ww")%>|<-- Previous Week]] (note no plus signs), then I got

[[The Lab/Weekly/May/2024-W21|<-- Previous Week]]

in a note with a name “2024-05-28”. W21 is the correct week. Adding the plus gave NaN’s instead of strings for the values. I wonder if the “+” gets associated with the ‘<%’ and that screws things up.

Not sure what else to tell you.

I have tried it that way as well, in fact I started that way and when it wasn’t working I went googling for help and I found someone that said adding +'s worked for them and it seemed to work for me…I’m not really sure what else to try? I’ve tried various symbols, spaces, no spaces, disabling/deleting Templater and Periodic Notes and then reinstalling, disabling, enabling Daily Notes and Templates core plugins…


I found this post

Which explains things really well. I got it figured out now.

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