[[FEATURE]] `now()` for front matter value in archetypes

@anthonyfok @mattstratton @bep @moorereason

Rationale

  1. Archetypes are a must for creating consistent metadata for sites that have multiple authors, as noted by @mattstratton. Single-author sites have less of a need (mentioned in a few different ways on the forums) since individuals can create sublime snippets, bash scripts, etc, but this detracts from the single-binary sexiness of Hugo and the archetypes feature as a whole.
  2. Hugo already has multiple baked-in date-related params/variables set in front matter: publishdate, lastmod, expirydate, date (one of two fields of the, er, archetypal archetype), etc.

What about adding the option to specifically call out now() arbitrarily for any user-defined field? Here’s an example for archetypes/post.md:

---
publishdate: now()
arbitraryfield: now()
expirydate: ""
description: ""
tags: [tag1, tag2]
categories: ['base category']
---

Then running hugo new post/my-new-post.md would generate the following. I’m writing this alphabetically to acknowledge that sorting is a a separate issue and not part of this request:

---
arbitraryfield: 2017-02-12T08:50:02-08:00
categories:
- base category
date: 2017-02-12T08:50:02-08:00
description: ""
expirydate: ""
publishdate: 2017-02-12T08:50:02-08:00
tags:
- tag1
- tag2
title: my new post
---

I can’t speak to the level of difficulty for adding this feature, so I’m looking for feedback on the utility of the request before putting in to GH. Thanks!

Related

https://discuss.gohugo.io/t/archetypes-vs-draft-true/587/3?
https://discuss.gohugo.io/t/setting-publishdate-in-an-archetype/4541/4

Semi-Related

https://discuss.gohugo.io/t/more-control-in-hugo-new-post-xyz-md/397/7

I think the solution here is to parse the archetypes as Go templates and allow all of Hugo’s built-in funcs, so:

---
publishdate: {{ now }}
arbitraryfield: {{ now }}
expirydate: ""
description: ""
tags: [tag1, tag2]
categories: ['base category']
---

Note that the example in that GH issue is bad. Slug will not be available at that time.

If we fix the above, we should probably also fix this in the same go:

Glad I threw this out there. That’s an even better idea!