Skip to main content
  1. 2024/
  2. Posts from April/

Multilanguage archetypes

Making it a bit easier to get thoughts outℒ️.

looking around, I didn’t find a lot of good guidance on using archetypes in a multilang site context.

here’s what I’ve found:

inside your project’s archetypes folder, create a subfolder per lang:

. (wpl_main)$ tree archetypes/
archetypes/
β”œβ”€β”€ brk
β”‚   β”œβ”€β”€ wplblog.md
β”‚   └── year.md
β”œβ”€β”€ default.md
β”œβ”€β”€ post.md
β”œβ”€β”€ wplblog.md
└── year.md

2 directories, 6 files

then, assuming a content structure like:

 tree
.
β”œβ”€β”€ 2021
β”‚   β”œβ”€β”€ April
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ August
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ December
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ February
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ January
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ July
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ June
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ March
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ May
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ November
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ October
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ September
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ _index.brk.md
β”‚   └── _index.md
β”œβ”€β”€ 2022
β”‚   β”œβ”€β”€ April
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ August
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ December
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ February
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ January
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ July
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ June
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ March
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ May
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ November
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ October
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ September
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ _index.brk.md
β”‚   └── _index.md
β”œβ”€β”€ 2023
β”‚   β”œβ”€β”€ April
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ August
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ December
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ February
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ January
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ July
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ June
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ March
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ May
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ November
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ October
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ September
β”‚   β”‚   β”œβ”€β”€ _index.brk.md
β”‚   β”‚   └── _index.md
β”‚   β”œβ”€β”€ _index.brk.md
β”‚   └── _index.md
└── 2024
    β”œβ”€β”€ April
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ August
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ December
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ February
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ January
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ July
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ June
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ March
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ May
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ November
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ October
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ September
    β”‚   β”œβ”€β”€ _index.brk.md
    β”‚   └── _index.md
    β”œβ”€β”€ _index.brk.md
    └── _index.md

53 directories, 104 files

and having the following content in archetypes/brk/wplblog.md and archetypes/wplblog.md

{{ $DAYT := replaceRE "((([0-9]{4})-([0-9]{2})-([0-9]{2})))-(.*)" "$1" .Name -}}
{{ $YYY  := replaceRE "((([0-9]{4})-([0-9]{2})-([0-9]{2})))-(.*)" "$3" .Name -}}
{{ $MMM  := replaceRE "((([0-9]{4})-([0-9]{2})-([0-9]{2})))-(.*)" "$4" .Name -}}
{{ $DAY  := replaceRE "((([0-9]{4})-([0-9]{2})-([0-9]{2})))-(.*)" "$5" .Name -}}
{{ $TYTL := replaceRE "((([0-9]{4})-([0-9]{2})-([0-9]{2})))-(.*)" "$6" .Name -}}
---
categories: ['']
contributors: ['evey-noblewise','atticus-skwirrelbane','penny-wise','anni-wise','wolf-noble']
date: {{ $DAYT }}
draft: true
kind: 'page' #values are page, home, section, taxonomy, or term.
publishDate: {{ $DAYT }}
series: [posts]
slug: '{{ $TYTL| lower}}'
description: '{{ replace $TYTL "-" " " | title }}'
summary: '{{ replace $TYTL "-" " " | title }}'
tags: ['{{$YYY}}']
title: '{{ replace $TYTL "-" " " | title }}'
type: 'posts'
weight: {{$DAY}}
---

Stuff I think is interesting, cool, or otherwise worth sharingℒ️.
Categories: 'enumerate' 'categories' 'you' 'use' 'here' Tags: 'emumerate' 'your' 'oft' 'used' 'tags' 'here' `hugo new 2024/April/2024-04-00-Example-Name.brk.md --kind brk/wplblog` `hugo new 2024/April/2024-04-00-Example-Name.md --kind wplblog` or... to save on postage title=hugo-tips; K=wplblog; PFX="`date +%Y/%B/%Y-%m-%d-`${title}" ; hugo new ${PFX}.md --kind ${K} && hugo new ${PFX}.brk.md --kind brk/${K}

then, you’ll have an easy near-one-liner to adapt for any style of post.

Set the environment var title in the first bit; and the variable K to the kind which aligns with the filename in your archetypes folder. then iterate through the ‘default’ lang, and any other language you want to generate content for.

There’s likely a better way to do this that I’m just not aware of yet.

Git_Repos/Wolfspyre.com/docker/blogsite (wpl_main)$ title=Hugo-Tips; K=wplblog; PFX="`date +%Y/%B/%Y-%m-%d-`${title}" ;hugo new  ${PFX}.md --kind ${K} && hugo new ${PFX}.brk.md --kind brk/${K}
Content "/Users/loiosh/NextCloud/Git_Repos/Wolfspyre.com/docker/blogsite/content/2024/April/2024-04-11-Hugo-Tips.md" created
Content "/Users/loiosh/NextCloud/Git_Repos/Wolfspyre.com/docker/blogsite/content/2024/April/2024-04-11-Hugo-Tips.brk.md" created

edit, post, repeat.