Archetypes can't use .Date.Local

Archetypes can’t use .Date.Local

File archetypes/default.md

---
title: {{ replace .Name "-" " " | title }}
date: {{ dateFormat "2006-01-02 15:04 MST" .Date.Local  }}
draft: true
---

Run hugo new post/1.md , out error massage.

Error: Failed to process archetype file "default.md"
:: template: default:3:48: executing "default" at
   <.Date.Local>: can't evaluate field Local in type string

hugo version is v0.55.6-A5D4C82D

It’s just a small problem, but I don’t want to change the time manually. I hope it can be solved.

Why do you want to change the date to local? I have in my archetypes:

date: {{ .Date }}
lastmod: {{ .Date }}

and it shows the proper time with proper timezone. Just asking. I could be wrong.

I said it before in another thread about this: That’s for Hugo, to sort by date(/time), not for you to read. If it gives you a weird time but the timezonestamp fixes it then that is ok.

1 Like

Oh, I see. Thank you for your explain!

So, .Date is a string. If you want the same date as a time object use now, so, now.Local etc. works.

3 Likes