# Multilanguage problem

**URL:** <https://discourse.gohugo.io/t/multilanguage-problem/52412>\
**Category:** support\
**Created:** [November 13, 2024, 6:29pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412 "2024-11-13T18:29:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 13, 2024, 6:29pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/1 "2024-11-13T18:29:53Z")

</div>

Hello everyone, before posting i was trying to use chat gpt and of course i was searching solution on this forum and stackoverflow… I have problem with adding to theme language switcher.

simple code:

```auto
<ul>
{{ range $.Site.Home.AllTranslations }}
<li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
{{ end }}
</ul>

```

generates:

```auto
<li><a href="//localhost:1313/pl/">Polish</a></li>
<li><a href="//localhost:1313/de/">Deutsch</a></li>
<li><a href="//localhost:1313/"></a></li>

```

That blank link should be defalul English.

I tried everything and im really tried. Maybe you can help me with this?

My env:

```auto
hugo v0.138.0+extended+withdeploy darwin/arm64 BuildDate=2024-11-06T11:22:34Z VendorInfo=brew
GOOS="darwin"
GOARCH="arm64"
GOVERSION="go1.23.2"
OptionParser::InvalidOption: invalid option: --embedded
  Use --trace for backtrace.
github.com/sass/libsass="3.6.6"
github.com/webmproject/libwebp="v1.3.2"

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 13, 2024, 6:41pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/2 "2024-11-13T18:41:07Z")

</div>

Please share your site configuration, or a link to your site’s public Git repository.

---

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 13, 2024, 6:43pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/3 "2024-11-13T18:43:55Z")

</div>

Here is my config.toml:

```auto
defaultContentLanguage = 'en-US'
defaultContentLanguageInSubdir = true

[languages]
  [languages.en]
    contentDir = 'content/en'
    languageCode = 'en-US'
    languageName = 'English'
    weight = 1
  [languages.pl]
    contentDir = 'content/pl'
    languageCode = 'pl-PL'
    languageName = 'Polish'
    weight = 2
  [languages.de]
    contentDir = 'content/de'
    languageCode = 'de-DE'
    languageName = 'Deutsch'
    weight = 3
[module]
  [module.hugoVersion]
    extended=true
    min = "0.41.0"
    
[markup]
  [markup.goldmark]
    [markup.goldmark.parser]
      [markup.goldmark.parser.attribute]
        block = true
        title = true
  [markup.highlight]
    anchorLineNos = false
    codeFences = true
    guessSyntax = false
    hl_Lines = ''
    hl_inline = false
    lineAnchors = ''
    lineNoStart = 1
    lineNos = false
    lineNumbersInTable = true
    noClasses = true
    noHl = false
    style = 'rrt'
    tabWidth = 4
  [markup.tableOfContents]
    startLevel = 2
    endLevel = 3
    ordered = false

[params]
  [params.theme_config]
    appearance = "retro"
    back_home_text = "↩︎ back"
    date_format = "2006-01-02"
    categories = true
    tags = true
    post_limit = 10
    show_more_url = "posts"

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 13, 2024, 6:44pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/4 "2024-11-13T18:44:21Z")

</div>

> [@tonsura](#):
>
> ```auto
> OptionParser::InvalidOption: invalid option: --embedded
> Use --trace for backtrace.
> 
> ```

Also, if you’re transpiling Sass to CSS using the “dartsass” option, you’ll need to [install Dart Sass](https://gohugo.io/functions/css/sass/#dart-sass) instead of whatever sass executable is currently installed.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 13, 2024, 6:47pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/5 "2024-11-13T18:47:54Z")

</div>

With the site configuration above Hugo throws an error, as expected:

> failed to decode “languages”: config value “en-us” for defaultContentLanguage does not match any language definition

If I change this:

```plaintext
defaultContentLanguage = 'en-US'

```

To this:

```plaintext
defaultContentLanguage = 'en'

```

I get this:

```plaintext
<ul>
  <li><a href="http://localhost:1313/en/">English</a></li>
  <li><a href="http://localhost:1313/pl/">Polish</a></li>
  <li><a href="http://localhost:1313/de/">Deutsch</a></li>
</ul>

```

You’ll need to share your project if you need additional assistance.

---

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 13, 2024, 7:12pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/6 "2024-11-13T19:12:43Z")

</div>

can i share via wetransfer? [Unique Download Link | WeTransfer](https://we.tl/t-xNRnqt3UwS)  
im total newbie in terms of git

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 13, 2024, 10:28pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/7 "2024-11-13T22:28:42Z")

</div>

I found this in your site config:

```plaintext
defaultContentLanguage = 'pl-PL'

```

Which causes Hugo to throw an error, as expected:

```plaintext
Error: failed to create config from result: failed to decode "languages": config value "pl-pl" for defaultContentLanguage does not match any language definition

```

When I change it to the correct value:

```plaintext
defaultContentLanguage = 'pl'

```

The site builds without error and the language switcher works great.

---

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 14, 2024, 8:25am UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/8 "2024-11-14T08:25:00Z")

</div>

thanks for your answer, this really makes me wonder because according to what you write I measured the value to “pl” (and to “en”) and I still have the same thing. also I created a new directory with a clean hugo to check and all the time it doesn’t display my switcher correctly.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 14, 2024, 3:11pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/9 "2024-11-14T15:11:03Z")

</div>

I’m not sure what to tell you; I cannot reproduce the problem with your site and the configuration correction that I described above. Maybe you can look at this simple working example to figure out what you’re doing differently/wrong:

```plaintext
git clone https://github.com/jmooring/hugo-multilingual-example
cd hugo-multilingual-example
hugo server

```

---

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 15, 2024, 12:53pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/10 "2024-11-15T12:53:00Z")

</div>

Thank you. The problem was of course stupid simple - I puted info about languages in config.toml instead of hugo.toml.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 15, 2024, 1:13pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/11 "2024-11-15T13:13:27Z")

</div>

You can name the site configuration file either “config.toml” or “hugo.toml” (preferred). I’m not sure what you did, but the “fix” has nothing to do with the file name.

---

<div class="post-metadata">

**Author:** ![tonsura](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tonsura](https://discourse.gohugo.io/u/tonsura)\
**Post date:** [November 15, 2024, 1:23pm UTC](https://discourse.gohugo.io/t/multilanguage-problem/52412/12 "2024-11-15T13:23:24Z")

</div>

the problem was probably due to the fact that I had config.toml and hugo.toml - and the data from these two files overlapped
