Multilingual / Multihost site with a single content folder?

Is there an option to create multihost and multilingual site from a single content/ folder?

So, all content is created in English, but in other languages, we’ll have small changes and we’ve decided to add a few .Params in the content front matter.

I’ve tried mount:

[module]
  [[module.mounts]]
    source = 'content'
    target = 'content/en'

  [[module.mounts]]
    source = 'content'
    target = 'content/de'

but this won’t work.

Also, I’ve tried to set contentDir for a few languages as content/. Again, it does not work.

Perhaps this can help?

no, this is not my case
I won’t have .md for any languages other than English

I need a way to generate pages for languages X, Y, Z, etc. from content for language E

If your md file is English it will also contain the English front matter values. And Obviously you cannot “edit” mounted stuff.

How do you plan to add the translated parts?

untested but you should be able to put your content files in a common-content folder:

[module]
  # default mount (required)
  [[module.mounts]]
    source = 'content'
    target = 'content'

  [[module.mounts]]
    source = 'common-content'
    target = 'content'
  [[module.mounts]]
    source = 'common-content'
    target = 'content/de'

or maybe put your md files in a subdirectory (untested and unsure)

defaultContentLanguageInSubdir = yes

[module]
  # default mount (required)
  [[module.mounts]]
    source = 'content'
    target = 'content'

  [[module.mounts]]
    source = 'content/en'
    target = 'content/de'

usually I would put the common stuff in data files and have small front matter only pages for the languages or use translation tables and/or i18n.

just tested, not works

looks like the best will be to store the content in content/en and make cp -rf content/en content/de for all languages right before hugo run

https://discourse.gohugo.io/t/do-all-page-bundles-need-localized-copies-once-you-add-a-new-language/37225/12

can’t figure out how this works

[languages.en]
baseURL = 'https://site-staging.netlify.app/'
languageName = 'English'
contentDir = 'content/en'
weight = 1

[languages.de]
baseURL = 'https://site-staging-de.netlify.app/'
languageName = 'Deutsch'
contentDir = 'content/de'
weight = 2

[module]
  [[module.mounts]]
    source = "content"
    target = "content"

  # EN content
  [[module.mounts]]
    source = 'content/en'
    target = 'content'
    lang = 'en'

  # DE content
  [[module.mounts]]
    source = 'content/de'
    target = 'content'
    lang = 'de'

  # Fill in the missing translations
  # This fills in the gaps in DE content with EN content
  [[module.mounts]]
    source = 'content/en'
    target = 'content'
    lang = 'de'

the content folder:
-\ content
|-- en
|---- post
|------ 1.md
|------ 2.md
|------ 3.md

so, there is no de/ directory

–========–
This builds into:
-/ public/
|-- en/
|---- en/
|------ 1.html
|------ 2.html
|------ 3.html
|---- 1.html
|---- 2.html
|---- 3.html
|-- de/
|---- 1.html
|---- 2.html
|---- 3.html

So, I got one more en/ directory inside of en/

Compare your configuration file to the example. Yours is different.

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