How to use same contentDir in multi languages

I want to use same contentDir if other language code.

My config.toml is as follows:

[languages.ja_jp]
LanguageName = "Japanese"
contentDir = "content/ja"
languageCode = "en-JP"

[languages.en_us]
LanguageName = "English(US)"
contentDir = "content/en"
languageCode = "en-US"
  
[languages.en_gb]
LanguageName = "English(GB)"
contentDir = "content/en"
languageCode = "en-gb"

However, pages render only one as using same contentDir.
http://localhost:1313/en_us/ has page. But http://localhost:1313/en_us/my-first-page/ is 404.

$ hugo serve

                   | JA | EN GB | EN US  
-------------------+----+-------+--------
  Pages            | 43 |    61 |     7  
  Paginator pages  |  0 |     0 |     0  
  Non-page files   |  0 |     0 |     0  
  Static files     | 82 |    82 |    82  
  Processed images |  0 |     0 |     0  
  Aliases          | 10 |     5 |     2  
  Sitemaps         |  1 |     1 |     1  
  Cleaned          |  0 |     0 |     0

Is it possible that use same contentDir?

Sorry, I have resolved.
It is not possible that use same contentDir with different language code

The value of contentDir can be any valid path – even absolute path references. The only restriction is that the content directories cannot overlap.

It is perfectly possible to use the same contentDir if you don’t identify it under each language, just use one dir for the whole website. This repo has two language websites (en and ru) that share the same content dir.

2 Likes

Thank you for your advice!
I have not known that it can specify multi-language codes if only one contentDir.

Unfortunately, my case needs to have multi-language codes and multi contentDir.

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