Hugo Archetypes

The folder ./archetypes and .themes/../archetypes hold the templates for newly created content.

When I type

hugo new content content/posts/hugo-archetypes.md

then Hugo will look for a template in the first directory, then in the second. This way I can overwrite the directory from which the template will be used, my own or that of my selected theme.

I use this template

---
date: '{{ now.Format $.Site.Params.fmt.ISO8601 }}'
draft:  true
title: '{{ replace .File.ContentBaseName "-" " " | title }}'
---

and you might ask why don’t you use {{ .Date }}? I don’t like the date format which is way too precise for my daily posts. But .Date is a preformatted string, that’s why I have to use now.Format.

BTW now is an alias for time.Now.

Reference: bep’s answer on discourse.gohugo.io

2024-12-19


copyright 2025 mobilarte