Set date in front matter from `hugo new` command

Heya folks! :wave:

I’m trying to set the date front matter in a hugo new command, but I’m just can’t recall how it works.

The idea is that I would do something like hugo new /2008-01-15-daily/ --another-thing=2008-01-15 and using archetypes/ it would produce, at content/2008-01-15-daily/

title: "Daily entry for 2008-01-15"
date: 2008-01-15

How do we pass commandline parameters to front matter, via archetypes? :thinking:

Option 1


date = [':filename', ':default']


Fetches the date from the content file’s filename. For example, will extract the date 2018-02-22. Also, if slug is not set, mypage will be used as the value for .Slug.

Option 2


title = '{{ replace .Name "-" " " | title }}'
date = {{ or (os.Getenv "HUGO_DATE") .Date }}
draft = false

Then create a new page with

HUGO_DATE=2008-01-15 hugo new
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.