Zettlr: [FEATURE] YAML Frontmatter templates

Created on 4 Feb 2020  Â·  15Comments  Â·  Source: Zettlr/Zettlr

Description

I would like to have new documents populated with pre-filled YAML frontmatter. It would also be pretty cool if I could choose between a few templates I have saved in settings (but I think that might be scope-creep).


Example Workflow

Quick solution: Have a section in "Settings" that lets users pre-filled everything between frontmatter fences (the "---"s). This mutates a template file in ~/.configs/Zettlr folder. When a new document is created, this file is copied over as the new file (or some cat-like thing is used to pipe into the new document if you are concerned about file properties).

Longer solution: Also include a way in settings to manage several of these templates and populate color-textured buttons alongside the "+" (for new file), that correspond to each template.

If going with the first solution, a second button may still be desirable for a "blank new document" vs. a "templated document." If opting for the quick solution, and open to the multi-template solution long-term, I implore you to model templates as a singleton list so that you can simply expand the list in the future. There is much less pain this way.

Caveats

Settings would be affected. The New File button might be affected -- or just the UI, in general. Also "Exporting" will change on a file-by-file basis since pandoc inspects frontmatter (which might indicate that this is an "advanced" feature). If the templates correspond to the entire document, you might want some sort of UX telling non-advanced users that changing frontmatter can effect document outputs.

All 15 comments

Have a look at #90 — once it's implemented, it's possible, I think

I think that would be a good proxy! Thanks, @nathanlesage !

You're welcome! It'll not make it into 1.6 but in 1.7 I'll finally include that thing! It's been open for too long I think :D

(I'll be closing this issue to keep the issue list clean, if I forget to do it until beta 1.7, please feel free to comment on one of the issues to remind me!)

I am using a nifty oss tool called espanso for this task with a snippet like this:

- trigger: ",yaml1"
replace: "---\ntitle: \nauthor: me\nid: {{mydate}}\nkeywords: \nstatus: #created\nabstract: \n---\n\n"
vars:
- name: mydate
type: date
params:
format: "%Y%m%d%H%M%S" # this ist the Zettlr ID format

Regards
Christoph

You're welcome! It'll not make it into 1.6 but in 1.7 I'll finally include that thing! It's been open for too long I think :D

(I'll be closing this issue to keep the issue list clean, if I forget to do it until beta 1.7, please feel free to comment on one of the issues to remind me!)

create a milestone or label for 1.7, without that you will forget features that should go there

I already have projects for this purpose.

Hello, and thanks for a really thoughtful and well-designed piece of software!

I'm just popping on to make the case for reopening this issue. It's not just YAML headers that would benefit; when I settle on a solution (I'm currently shopping), it'll most likely pair with 1Writer on my phone/iPad, which means that the most sensible format for a Zettel will be something like

202004191340

Tags:
(etc.)

or something like it. I can do this with the snippet tool in #90 or a different solution, of course, but the lag between note filename creation and the triggering of the snippet means that some percentage of notes will have a filename that differs from the internal tag by one minute. This is far from the end of the world, but a more elegant fix would be simply to let me specify some Javascript that would populate new notes upon creation.

Just my perspective, ymmv, etc., and thanks again.

Yeah, this will be one use-case for #90!

Oh! Then I misunderstood how #90 was going to work. Never mind, and thanks!

hi @bfbraum I dont fully understand your request, but on 1Writer I use Action Directory / Zettelkasten Titel http://1writerapp.com/actiondir/action/7a294

Right, I use something similar. In 1Writer, though, the time stamp in the file name is drawn from the first line of the file, so the time stamp and the file name will always be the same. The way Zettlr works, though, the time stamp in the file name is generated when you click + to create a new file. If you use a system in which you add a substantive name to the filename (e.g., 202004241312 A New Thought.md), that takes a few seconds to enter, at least. If you have to then use a key combination to paste the template into the blank Zettel, that's another second or two. So by the time the template generates a time stamp inside the file, there's a nontrivial chance that it will have incremented and will no longer match the time stamp in the file name.

If the template is generated at the same time as the file name, of course, this is not an issue. But I couldn't figure out from #90 whether that was the case.

So by the time the template generates a time stamp inside the file, there's a nontrivial chance that it will have incremented and will no longer match the time stamp in the file name.

You can right-click the file to copy its ID (in the file list), this way you have the same, not a new one!

Ah! Perfect. Thank you!

@nathanlesage, I can't find the feature, were YAML frontmatter templates added in 1.7? If not, could you reopen the issue?

Update: Closing in favor of #1009

Was this page helpful?
0 / 5 - 0 ratings