Nested Templates

Hello everyone, don’t typically use forums for specific programs myself but I’ve been a big fan of Obsidian since I first discovered it a number of months ago. There’s a number of things I’ve thought of requesting but this one has stuck out the most from my end. Hopefully an explanation of where I’m coming from will help present exactly what I’m talking about.

Obsidian has been a great resource in referencing information regarding Youtube video projects that I put together as a hobby. A lot of these pages for these projects to help keep track of everything involve repeatedly the same information, such as project names in video editors or gathering lists of sources for information, that sort of thing. So far I’ve stuck with using headers for separating these categories within these notes, and it definitely works however it becomes cumbersome when you add an extensive to-do list on the same page and a lot of images.

The idea here is, to help organize these notes, is to have an extended note created within each template, that is attached to each new note created using that template. Note, I don’t mean to reference a note already existing when creating a new note, but creating a “note within a note”, generated by the template itself. For those familiar with Notion, this would be akin to having a template within Notion that has another page created within that page. I believe this would really streamline the process for organization structures like this, especially in instances where the user is constantly filling out similar information based around particular projects into a single place for reference, simply saving a lot of time creating new notes that are only going to be used in the one note.

Hopefully everyone gets what I mean. I tried searching around a bit to see if anyone else had discussed such a topic, but couldn’t find much luck. Also, if such a thing really does work in the current version I really couldn’t figure that out.

5 Likes

Interesting. Is this not possible with the current Template feature? I imagine you could create a template that includes the line:

![Some Note]

Also, this is related, I think: Note extractor

(PS: Welcome to the forum!)

I see what you’re saying with the embedded note references, and while those are definitely good tools for referencing other material directly in another note that isn’t exactly what I was going after. Sorry for any confusion.

What I meant more specifically is templates including new notes generated along with that template, where the new notes generated also have some pre-determined lines to save time formatting and such. Maybe putting it like this will help.

  • [[Template A]]
    ⮩ [[Template B]]
    ⮩ [[Template C]]

Where [[Template A]] is the main, overall template, and within that template there is also new notes, in this case [[Template B]] and [[Template C]], both of which also have their own text generated. This would mean when creating a new note based off of [[Template A]], it would also generate [[Template B]] and [[Template C]], which I’d imagine would be referenced in [[Template A]].

Apologies for any confusion again, it seems to get difficult to explain these sorts of things simpler when we start going into “notes within notes” and the like haha.

Overall I just believe this sort of functionality would save time organizing new notes when structured in a similar way, save the process of copy-pasting other bits of text. I’d imagine to make this work it’d involve either ZK UIDs or some manner of variable-based note names that go along with the new notes.

Thanks for the warm welcome!

Ah, interesting. Well, the current template feature can do this halfway right now, maybe… If your Template A looks like…

Some text
- [[Template B yyyyMMddhhss]]
- [[Template C yyyyMMddhhss]]

…where yyyyMMddhhss are timestamps using the Template’s syntaxes, those two notes would be created as orphans. They could then be manually filled with more templated content.

But yes, I get what you’re going for. Nested templates, essentially. A good candidate for a plugin, I imagine.

Alternatively, you could probably use automation/macro tools to create these nested templates using e.g., Keyboard Maestro (macOS) or AutoHotKey (Windows).

2 Likes

Cool feature request. I hadn’t thought of it, but now I need it.

I think that “Nested Templates”, as suggested by @ryanjamurphy, would be a better title for this. It made things a lot clearer for me, at least.

2 Likes

With my rather fuzzy concept of what’s being looked for, I would have expected text expander or macro being the way to go. And probably easier, once set up, than any native solution. I’d use PhraseExpress, but that’s only because I have a glimmer of how it works.

3 Likes

There’s some serious recursion and the danger of self-reference loops, but I think it could be done in Alfred, for example. There goes my spare time.

1 Like

Nested templates is a much more elegant name for what I’m talking about! I’m glad you were able to shorten what I meant.

On another note though, how would one go about using the syntaxes like you mentioned? I can’t seem to find exactly how that’s done this second. Would be very helpful.

I’ve considered trying to make some sort of macro to do the same job for the mean time but figured I’d throw it out here on the forums before attempting anything haha.

Sorry, I was writing out the above off the top of my head, so it might not work exactly as I described.

The templates documentation is here: https://publish.obsidian.md/help/Plugins/Templates

You should be able to use e.g., [[Note title {{date}} {{time}]] inside a template to generate those orphan notes unique to every new template.

1 Like

Yep, +1 for “Nested Templates” or “Modular Templates” or “Meta-Templates”

The application here is a parent/meta/main template that has child/module/section templates embedded into it upon creation.

First question might be, why not just construct the main template to include everything you want? A: Well, being able to reuse the module templates in other meta-templates allows for consistency for sections that repeat. And when changing a child template, it changes in every meta-template it appears under.

Q: why not embed a file with the ![File]? This is good for getting the same file to reappear, but not if you change that file. It would no longer be a template, just a single file that is always changing.

Q: why not link to a file with the [File]? See above.

Solution:
Just allow a template to contain a reference to another template with {{Child Template}} format.

Warm welcome to any alternate ideas or workarounds.

2 Likes

Definitely interested in this feature. As a developer by day, nested templates make sense to modularize my templating.

I want the ability to have re-usable ‘footer’ and ‘header’ sections across a vast majority of my templates and having a single place to modify those sections for future files makes a lot of sense.

With that being said thanks for such a great product, I’ve been deep diving on Obsidian a lot recently.