Mastodon hachyterm.io

Hugo offers the ability to create template files for your project. These Archetypes will make your life easier by pre-filling a blog post for you.

How To Create A New Template

In your Hugo project, create a new Markdown file in the archetypes folder in the project directory, for example, archetypes/posts.md.

Here’s a template that creates a new draft post with the current date in a specified format. For the title section we parse the filename and use a regular expression to convert dashes to whitespace. Finally, we title-case the string.

---
date: '{{ now.Format "Monday, January 2, 2006"}}'
title: '{{ .File.TranslationBaseName | replaceRE "-" " " | title }}'
draft: true
---

After you’ve created a template, you can use it with hugo new <template-name>/<file-name>.

Example:

hugo new posts/my-new-blog-post.md

Result:

---
date: 'Thursday, November 21, 2019' 
title: 'My New Blog Post'
draft: true
---

Further Reading