Do all page bundles need localized copies once you add a new language?

There are two approaches that I can think of.

1. Use lang.Merge

See https://gohugo.io/functions/lang.merge. This is for filling in gaps when you are iterating (ranging) through a collection of pages (e.g., on a list page).

2. Mount the en directory on top of the de directory

structure

content/
├── de/
│   ├── _index.md
│   └── test-1.md    <-- Note that test-2.md and test-3.md are not present
└── en/
    ├── _index.md
    ├── test-1.md
    ├── test-2.md
    └── test-3.md

config.toml

[languages.en]
weight = 1
[languages.de]
weight = 2

# EN content
[[module.mounts]]
source = 'content/en'
target = 'content'
lang = 'en'

# DE content
[[module.mounts]]
source = 'content/de'
target = 'content'
lang = 'de'

# This fills in the gaps in DE content with EN content
[[module.mounts]]
source = 'content/en'
target = 'content'
lang = 'de'

And when you build the site…

public/
├── de/
│   ├── test-1/
│   │   └── index.html
│   ├── test-2/
│   │   └── index.html
│   ├── test-3/
│   │   └── index.html
│   └── index.html
├── en/
│   ├── test-1/
│   │   └── index.html
│   ├── test-2/
│   │   └── index.html
│   ├── test-3/
│   │   └── index.html
│   └── index.html
└── index.html

Try it:

git clone --single-branch -b hugo-forum-topic-37225 https://github.com/jmooring/hugo-testing hugo-forum-topic-37225
cd hugo-forum-topic-37225
hugo server
6 Likes