Customized Archetype for This Site

Background

I prefer including the date into the Permalink of a post. Everytime I create a new post, I type

hugo new post/$(date -I)-post-title.md

to ensure that the date is correct.

Problem

The title field in the post’s front matter contained the date, which wasn’t something that I wanted because it’s already shown next to the icon.

Observations

Neither \d nor [\d] works for the PCRE character class \d.

Solution

I tried piping replaceRE, but I didn’t manage to get it work. Thanks to this Hugo forum answer, I’ve finally solved the problem.

---
title: "{{ slicestr .Name 11 | humanize | title }}"
date: {{ .Date }}
categories:
- uncategorised
tags:
- notag
draft: true
---

The number 11 comes from the character count of 2019-08-10-.

Hugo 

4 comments

Your email address will not be published. Required fields are marked *.