{{fileName}} for Templates, where the file name of the note automatically gets inserted into {{fileName}}

Use case is for example a note with table of contents, or a template where links are automatically scattered to go to different headers within the note.

I don’t quite understand what you are trying to do… Can you give a more detailed example of your possible use case(s)?

@alltagsverstand Oh it’s just that right now I use the Daily Note. Sorry I meant File Name instead of Title! {{fileName}}

And I formatted it such that it has different headers for the things I’m trying to keep track of. So I have a checklist at the start of the note or a “table of contents”.

I just thought it would be more convenient to click a link to go to a section, for example “Sleep Tracking”, and then click a link to go back to the checklist header which would be for example:

## Checklist
- [ ] Enter sleep tracking
   - [[{{fileName}}#Sleep Tracking]]

[...]
## Sleep Tracking
Time: 
[[{{fileName}}#Checklist]]

I realize that I could do this by just setting a [[{{fileName}}#Header]] etc. scattered throughout the note, and then just doing a Find and Replace for the {{fileName}} manually. But since it’s a note template anyway, I thought might as well have that {{fileName}} as part of the template variables.

I thought it might be useful as well for building small Wiki templates with Table of Contents.

Do you mean {{title}}? Use this in templates it will auto insert the “title”(filename).

1 Like

Oh thanks! I didn’t know that existed :smiley: Wasn’t in the Templates settings nor the docs https://publish.obsidian.md/help/Plugins/Templates.

Stoked it’s actually there :smiley:

Yeah I’m also wondering why it isn’t involved in docs. Came across it in discord not long ago. Such a must-have placeholder.

Hmm, but why do you need the file name at all of the respective note in order to jump back and forth?

By putting something like [[#Sleep Tracking]] into your TOC it will create an automatic link to the respective (sub)heading; from there you can in a similar way link back to your TOC heading…

1 Like

Oh. I just didn’t know that one could reference headers like that in Markdown :joy: Thanks for this tip!

In addition, obsidian includes a TOC/Outline plugin. You can open the outline of your current note with a hotkey and then just jump between the different headings by just clicking them.

1 Like