Templater: Add 'Parent Folder' to 'related' frontmatter property

I have a property named related where i link all sorts of notes or links. I created a template which adds the parent of this note as a related link.

Here’s how it appears for me:

---
created: 2024-10-28
related:
- "[[Video Encoding]]"
- other related things
---

And here’s the template:

<%* 
const propertyName = "related"

// get path (relative to vault) for current note
const notePath = tp.file.path(relative=true)
	
// get Obsidian.TAbstractFile for current note
const tFile = tp.app.vault.getAbstractFileByPath(notePath);

if(!tFile.parent?.isRoot()) {
    const parentName = tFile.parent.name
    const parentLink = `[[${parentName}]]`
    
    tp.app.fileManager.processFrontMatter(tFile, frontmatter => {
        if(!frontmatter[propertyName].contains(parentLink)) {
            frontmatter[propertyName].push(parentLink)
        }
    })
}
%>

This was inspired by Templater and Obsidian API: list parent folders as internal links in note

It leads me to the question: why some users refers to the parent note in the frontmatter? Have not backlinks and forwardlinks got the same role already?

It looks prettier in the graph :smiley:

In all honesty, I don’t use tags. Instead, in each of my folders I have a note with the folder name which acts as the tag. Obviously, I use that note in other places which aren’t the current folder too.

Why have a note with the folder name? Well, because tags do not allow me to add any information to them, while that node does. It’s a note afterall.