I completely agree. I think the concept behind hugo new
is a step in the right direction, but there are many more steps.
In fact, I found your post when creating a post to see if there is interest in having hugo new
look for an env var so I don’t have to be in the exact perfect place for it to work when I call the command. If there is enough interest perhaps we could open a thread and dialog about it. I image many of gotten around this annoyance in their own way, custom scripts, aliases, etc.
One quick way to get around the limitations of the archetype system is to use _.md
files. I use these a lot. The _
means “archi/prototype” to me and I use this method for both stuff in content
and data
. Even without a helper cp _.md my-new-post-md
works pretty well and like most shell folk I have a tstamp
command of my own for adding in the time stamp. I just have to make sure all my templates ignore _.md
in the .Pages
list, which is something I wish Hugo did automatically.
In the data
directory I use this and make liberal use of directories and subdirectories for modeling data defaulting to objects/maps over arrays/slices/lists any time I can. TOML currently does not support the field = {some="thing}
syntax, which it declares in its spec, so subdirectories work. They also play more nicely with automation and navigation. Using cd
to navigate your data model is pretty nice (v.s. the equivalent from a MongoDB REPL, for example. The _.toml
file is the equivalent of a JavaScript prototype in my world. Not only does it give me something to copy and fill in when adding new data, It allows me to give all the objects properties that they all share unless overriden. Obviously the annoyance here is that I have to do the overriding logic in my templates. Eventually I am hoping to submit a PR for a protodata = true
or something that allows this to happen automatically.
But back to the hugo new
thing.
One major annoyance I have, that has caused me to all but not use hugo new
is that as soon as I close the file I cannot open it again with the same command (by going back up in history). I mean, how many of us get it right on the first pass, lol. To open it a second time I have to go to the content/blog
directory anyway so might as well just started out there.
It seems like hugo new
and the like almost need their own project or subproject. One that focuses on working with the content
and data
directories.
On a related note I think Hugo could be simplified to not need hugo new site
to begin. On the whole it could really benefit from some basic assumptions and simplified starting setup, but that one is less urgent to me.