What I mean is I have a template, that is used a crossed multiple notes, if I need to update it then I have to go through every single note that uses that template. So is there a way to auto update every note that uses that specific template? When I try to look this up, I mainly use auto creating templates, but that’s not what I’m looking for. I need a way to auto update notes that have Template: (name here), not all other templates. Just the ones that have a specific name. Similar to how dokuwiki does.
i think you can do this with dataview and dataview publisher.
use dataviewjs to render the template contents and then dataview publisher to stamp it into the files in an update operation. any time you tweak the template and re-run dataview publisher update, the files you’ve specified for dataview publisher will run an update.
if you just want to see the template in the file, you could do an embed instead.
How would I do the dataview thing? I’ve never touched it.
for example, in a large portion of my notes, I have this code:
> [!QUOTE]+ `=this.file.name`
> ```dataviewjs
> await dv.view("scripts/header")
> ```
With dataview installed, it executes the code that’s in scripts/header.js (and in this case, renders it in a callout that bears the same name as the current note).
That header.js file can contain a lot of complex stuff, or it could be something as simple as dv.paragraph("hello")
.
The advantage of this approach is you can update what shows up in each note all from that one js file, and it can even vary per note by looking at the metadata of the note it was launched from.
if all you need from this repeating template is to be shown the same thing in each note, that’s the way I’d do it.
If it’s necessary to have a template that you then want to be able to modify per note, that becomes more difficult.
Basically it comes down to what you want to be able to do.
Again, this may be overkill, and you might get what you need simply by using embeds/section embeds, like ![[my template#my section]]
If you’ve created a file in the past based upon a template, then the train had left the station. There is no turning back from expanding/instantiating a template.
If that’s the case you’ve got to resort to search-and-replace across those files.
That’s why it’s usually in many scenarios (publish excluded) a much better option to use some dynamic query, like dv.view()
, to produce dynamic portion of your notes.
Cant seem to get the dataview one to work, but the ![page] seems to work. By “my section” do you mean linking to a header? The only downside I’ve found is that weird red line that appears on the top, and there doesn’t seem to be a way to have it reader as if in reading move while the note that the template is on is in live preview mode or to have it moved to the left. Do you know if there is a way to remove/hide the page title?
I think this thread covers removing embedded headers: