topics: hugo (tidbit)

Archetypes in Hugo

Archetypes are front-matter templates useful for prepopulating new content.

When creating content via the cli, e.g:

hugo new tidbits/hugo-archetypes.md

A ‘tidbits’ type is inferred from the directory structure and an attempt is made to resolve an archetype template.

By default Hugo will first check for archtypes/tidbits.md, then archtypes/default.md and finally the corresponding locations relative to the active theme.

Templating functionality may be utilised in the Archetype.

For example, to prepopulate the date:

date: {{ .Date }}

Taxonomy Archetypes

A taxonomy type page may have properties associated via a file. For a topic ‘hugo’ the file path is: content/topics/hugo/_index.md

These files can be created using an Archetype by the Hugo new command when provided with a --kind flag.

e.g.

hugo new --kind topics topics/hugo/_index.md

This results in a new content/topics/hugo/_index.md file pre-populated using the topics Archetype.