OneBite.Dev - Coding blog in a bite size

How to Customize Front Matter in Hugo

Learn how to customize you pre-defined fields in front matter in your hugo app

Slowly your Hugo app is growing, the default field you need in your front matter is not just title and date anymore, you always need to include description, tags, or any other field. Hugo provide archetypes as our default template when creating a new content.

The default location for this is in “archetypes/posts.md” or if you want in live in your theme “themes/my-theme/archetypes/posts.md”. Open this particular file and write

title: "{{ replace .Name "-" " " | title }}"
createdAt: {{ .Date }}
description: ""
tags: \[""\]
image: ""

It really depend on your needs, the above code is what i currently always write when starting a new post

← How to Create Simple Pagi...
How to Make Dynamic Twitt... →
hugo