Hugo - Multilingual with language fall back

See discussion: How to automatically fallback to the default language when a requested page doesn't have a translation?

Here is how I set it up for my website:

[module]
  [[module.mounts]]
    source = "content/en"
    target = "content"

  [[module.mounts]]
    source = "content/zh"
    target = "content"
    lang = "zh"

  [[module.mounts]]
    source = "content/en/docs" # zh missing-page fallback
    target = "content/docs"
    lang = "zh"

  [[module.mounts]]
    source = "content/en/blog" # zh missing-page fallback
    target = "content/blog"
    lang = "zh"

In addition, I commented out all contentDir settings in my hugo.toml according to the official document:

if you add a mounts section you should remove the old contentDir, staticDir, etc. settings.

Hugo and Docsy versions:

  • Hugo v0.125.6
  • Docsy v0.10.0

References

Last modified: 2024-08-20