Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with separating multilingual configurations into separate config files #5957

Closed
mostaja opened this issue May 14, 2019 · 3 comments
Closed
Labels

Comments

@mostaja
Copy link

mostaja commented May 14, 2019

Version v0.55.5-A83256B9

I started out with a barebones site by running hugo new site command, and also started out with a blank theme.

Then I configured the config.toml in the project root so that it supports multilingual site. The configuration is as follows:

baseURL       = "http://example.com"
languageCode  = "en-US"
title         =  "Title"
theme         = <theme-name-removed>

DefaultContentLanguage          = "en"
DefaultContentLanguageInSubdir  = true
hasCJKLanguage                  = true

disableKinds = ["taxonomy", "taxonomyTerm"]

[languages]
  [languages.en]
    languageName = "English"
    contentDir = "content/en"
    title = "Studio Tsubasa"
    weight = 1
    
  [[languages.en.menu.main]]
    url = "/en"
    name = "Home"

  [languages.ja]
    languageName = "日本語"
    contentDir = "content/ja"
    weight = 2
    
  [[languages.ja.menu.main]]
    url = "/ja"
    name = "ホーム"
    
  [languages.zh-tw]
    languageName = "繁體"
    contentDir = "content/zh-tw"
    weight = 3
    
  [[languages.zh-cn.menu.main]]
    url = "/zh-cn"
    name = "首页"
    
  [languages.zh-cn]
    languageName = "簡體"
    contentDir = "content/zh-cn"
    weight = 4
  
  [[languages.zh-tw.menu.main]]
    url = "/zh-tw"
    name = "首頁"

then, I moved config.toml into /config/_default. The website can still be built.
Then, I put the language configurations into another file called languages.toml

When I run hugo -v, I get the following error: site config value "en" for defaultContentLanguage does not match any language definition

Then, when I put DefaultContentLanguage = "en" into languages.toml, I get the following error: Failed to parse multilingual config: Language config is not a map: string

I then put the language configuration back into config.toml. Afterwards, I tried putting language-specific menu configs in their own files (menus.en.toml, menus.ja.toml, menus.zh-tw.toml, menus.zn-cn.toml). So I have config.toml and a couple of menus..toml files. I got the following error: unable to process menus in site config

Once line for each language

unable to cast map[string]interface {}{"en":map[string]interface {}{"menu":map[string]interface {}{"main":[]map[string]interface {}{map[string]interface {}{"name":"Home", "url":"/en"}}}}} of type map[string]interface {} to []interface{}

It seems like I have to keep everything inside the main config.toml in order for multilingual configurations to work. The screenshot on getting-started/configuration doc page under "Configuration Directory" seemed to state otherwise.

@mostaja mostaja changed the title Problems with separating configurations into separate config files Problems with separating multilingual configurations into separate config files May 14, 2019
@bep
Copy link
Member

bep commented May 14, 2019

I would recommend looking at this https://github.com/gohugoio/hugoDocs/tree/master/config/_default

If you have further questions, take them at https://discourse.gohugo.io/

@bep bep closed this as completed May 14, 2019
@mostaja
Copy link
Author

mostaja commented May 14, 2019

Thank you for the help!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants