1 minutes reading
Archtypes in Hugo
I’m using hugo for some time now. However, one aspect of hugo was always a problem for me: Creating new posts with
hugo new. This command will generate a new file with a minimal amount of meta-information necessary for a post. That’s the information above the written content like the title or the date. It also contains the option by default that the post is a draft.
I wanted to modify this behaviour for some time now. Extending the meta-information by categories and tags. But, I was never able to figure out the right configuration parameter to do so, until now. Hugo calls this feature ‘Archetypes’. This word is quite inconvenient and makes no sense in my opinion.
One detail that also requires some attention is the way this works. You’re writing a file into the folder
archetypes for the content type you want to have a template for. This is sensitive for suffix of the filename too. Adding a
archetypes/default.md will only affecting all files with a
.md suffix. In case you have files that have the
.markdown suffix it would affect them. To fix this, you should create for each file a default file.