Can I create a json archetype for data?

This is my first time creating a static site and I love how it takes a lot of the scripting work of serving up content how it does, but I have to generate a bunch of items for a store and wondering if I can do something similar to content archetypes but with json? Like this: hugo new item/item.mb

If this is not possible I can write my own build script that reads in a data file.

I don’t think archetypes can write to the data directory, but there are all kinds of way to read in data or generate data from page bundles. I suggest reading all the docs to get a sense of what is possible.

I’ve read the docs and there seems to be nothing on this subject.

In short, you can use complete directories as archetype templates – which is great if you want to create bundles (see https://github.com/gohugoio/hugoDocs/tree/master/archetypes/showcase for an example).

You can currently only have template syntax inside content files in a archetype template dirs, the other files are just copied. But note that you can put just about anything in the front matter of a content page, so that may be an option. Also see a recent discussion about transform.Unmarshal.

2 Likes