Set custom archetype fields when calling `hugo new`

Hello folks,

My question is in the same vein as Fill all Archetypes fields with hugo new, but I just want to double check. Didn’t find an answer in docs or discourse posts.

I have an archetype with some custom fields that I denote with <<fieldname>>. The << and >> merely serve as visual reminders to manually replace those values when filling out the content file. I’d rather set them when calling hugo new.

Here’s an example archetype:

title: Project <<phase>> | <<aspect>>
weight: 1
description: "Infor for <<aspect>> of phase <<phase>>"
phase: <<phase>>
aspect: <<aspect>> 
ccfooter: {{ .Site.Params.footer_cc_by_nyc_4_0 }}
date: {{ .Date }}
draft: true

I’d like to set <<phase>> and <<aspect>> when invoking hugo new, like:

hugo new foo/bar/ --archvar phase=Early --archvar aspect="Completion Time"

Of course, --archvar is not a valid parameter and is only for expressing my wish.

If not possible, I suppose chaining script or sed string substitution call after hugo new would do the trick.

Oh, and thanks for the hard work on Hugo. The more I use Hugo, the more I love it.


Hugo new has limited calculations during copying the archetype file as markdown file.
Must try to work around this with scripts.

Hi @Michael_Schwartz, as far as I know, what you want is not currently possible.

Thanks @ju52 and @zwbetz. Scripts are flexible and they mitigate bloat.

1 Like