I18n vs Params

After reading various sources in the past day or so, I find that adding translations to a theme I am creating for personal use makes me shift some entries from Params to the translation file. Is this recommended? Or should I create language specific Params?

In multilingual sites, language-specific values can exist in:

  • Configuration (examples: params, menus, properties in the root table)
  • Content (examples: foo.en.md, foo.de.me)
  • Layouts (examples: single.en.html, single.de.html)
  • The data directory
  • The i18n directory

So you’ve got some flexibility, which is great, but what’s the best way? To some extent this is a matter of preference, but the principle of least surprise can guide you.

Let’s say you want a language-specific subtitle for your home page. You could do this via any of the methods above, including content (i.e., a front matter value in _index.en.md and _index.de.md). But to me, the site’s subtitle is a site parameter, so it should go in the site configuration, just like the site title.

Another factor to consider is simplicity of maintenance. For example, I would rather maintain language-specific values in the i18n directory than have to hunt through language-specific layouts.

3 Likes

You are right. I am just now realizing the flexibility of Hugo. I looked into all these methods you pointed and I will stick with i18n.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.