# Set date in front matter from \`hugo new\` command

**URL:** <https://discourse.gohugo.io/t/set-date-in-front-matter-from-hugo-new-command/41069>\
**Category:** support\
**Created:** [October 24, 2022, 5:29am UTC](https://discourse.gohugo.io/t/set-date-in-front-matter-from-hugo-new-command/41069 "2022-10-24T05:29:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [October 24, 2022, 5:29am UTC](https://discourse.gohugo.io/t/set-date-in-front-matter-from-hugo-new-command/41069/1 "2022-10-24T05:29:56Z")

</div>

Heya folks! 👋

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/index.md --another-thing=2008-01-15` and using `archetypes/default.md` it would produce, at `content/2008-01-15-daily/index.md`:

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

```

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

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [October 24, 2022, 6:32am UTC](https://discourse.gohugo.io/t/set-date-in-front-matter-from-hugo-new-command/41069/2 "2022-10-24T06:32:23Z")

</div>

#### Option 1

config.toml

```auto
[frontmatter]
date = [':filename', ':default']

```

See:  
[https://gohugo.io/getting-started/configuration/#configure-dates](https://gohugo.io/getting-started/configuration/#configure-dates)

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

#### Option 2

archetypes/default.md

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

```

Then create a new page with

```bash
HUGO_DATE=2008-01-15 hugo new foo.md

```

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 26, 2022, 6:32am UTC](https://discourse.gohugo.io/t/set-date-in-front-matter-from-hugo-new-command/41069/3 "2022-10-26T06:32:48Z")

</div>

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