I could have sworn there was already a thread on this topic, but I cannot find it for the life of me so I’m opening this one again. Sorry if this is a duplicate.
I personally really liked Hugo’s command new
and kinda missed it in Zola. Espeically because I personally have a lot of sections that have a very specific structure but also the index.md
file has specific tags so having something to copy all of that easily is a big plus for me, though I admit it’s just a creature comfort thing.
The specific use case for me right now is making new publications. Every time I make a new publication it gets its own section for asset colocation, and has a bunch of fields like abstract, authors,pdf,bibfile,venue. Additionally it also has a sub folder called images
for images about that publication.
I’ve added an archetypes
folder, after Hugo’s function of the same name. This folder must at least contain a file called default.md
, which at the moment just looks like this:
---
title = "%TITLE%"
date = %ISODATE%
draft = true
---
Right now I have an implementation that works like this:
-
zola new temp-file-with-title.md
will copyarchetypes/default.md
over tocontent/temp.md
and change it’s title toTemp file with title
and the date to the current local ISO date. -
zola new type/subtype/specific-title.md
will look to use the filearchetypes/type/subtype/default.md
as a template- if it finds it it will do the same as before. if
archetypes/type/subtype/
contains other files or folders those get recursively copied over to the target directory without modification. - if it does not find it, it will still create the file along with the folders if necessary but use
archetypes/default.md
as a template
- if it finds it it will do the same as before. if
- if
content/type/subtype/specific-title.md
already exists, thenzola new type/subtype/specific-title.md
will do nothing
So far the implementation has tests for the most important functionality, but I don’t have coverage stats at the moment. I will be adding some documentation on it in the next few days if possible. The template functions that it supports are very simple atm but I figured it was a good enough start. Can I submit a PR with this?