Change language with Dropdown menu

If you want to include all translations, use the .AllTranslations method. And yes, you can definitely optimize your language switcher code. Here’s an example:

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

Files of interest:

  • layouts/partials/language-switcher.html
  • hugo.toml (see per language params to set flag)
1 Like