Multilingual website with two different home pages (one for each language)

Probably my question is dumb.
Currently, my website is based in two languages, and the architecture is the following:

/content
     |_ en
         |_ page
         |_ posts
     |_ it
         |_page
         |_posts

In my config.toml I have:

[languages]
  [languages.en]
    title = "NicFab Notes"
    languageName = ":gb: EN"
    languageAltTitle = "English"
    weight = 1
  [languages.it]
    title = "Note di NicFab"
    languageName = ":it: IT"
    languageAltTitle = "Italian"
    weight = 2

    [[languages.en.menu.main]]
    identifier = "home"
    name = "Home"
    pageref = "/"
    weight = 1
    [[languages.en.menu.main]]
    identifier = "about"
    name = "Me"
    pageref = "/about"
    weight = 2
    [[languages.en.menu.main]]
    identifier = "blog"
    name = "Blog"
    url = "https://www.nicfab.it"
    weight = 3
    [[languages.en.menu.main]]
    identifier = "archive"
    name = "Archive"
    pageref = "archives"
    weight = 4
    [[languages.en.menu.main]]
    identifier = "tags"
    name = "Tags"
    pageref = "tags"
    weight = 5
    [[languages.en.menu.main]]
    identifier = "privacy"
    name = "Privacy"
    pageref = "/privacypolicy"
    weight = 6
    [[languages.en.menu.main]]
    identifier = "search"
    name = "Search"
    pageref = "/search"
    weight = 7
          

    [[languages.it.menu.main]]
    name = "Home"
    pageref = "/"
    weight = 1
    [[languages.it.menu.main]]
    name = "Me"
    pageref = "/about.it"
    weight = 2
    [[languages.it.menu.main]]
    name = "Blog"
    url = "https://www.nicfab.it"
    weight = 3
    [[languages.it.menu.main]]
    name = "Archivio"
    pageref = "archives.it"
    weight = 4
    [[languages.it.menu.main]]
    identifier = "tags"
    name = "Tags"
    pageref = "tags"
    weight = 5
    [[languages.it.menu.main]]
    name = "Privacy"
    pageref = "/privacypolicy.it"
    weight = 6
    [[languages.it.menu.main]]
    name = "Cerca"
    pageref = "/search.it"
    weight = 7

I wondered whether it is possible to have a home page in Italian and another one in English.

By default the first language resides under the domain root.

If you want it under the language subdirectory -e.g. /en/- then you need to set defaultContentLanguage = 'en'

see: Configure Languages

Thank you.
In my config.toml I also have:

languageCode = 'en-us'
DefaultContentLanguage = "en"
defaultContentLanguageInSubdir = "true"

I wondered whether landing on my website and choosing a language (in my case IT or EN) the user can see - for example - the home page in Italian as different from the English one.

I wondered whether it is possible to have a home page in Italian and another one in English.

What exactly do you mean by that? You HAVE a home page in IT and one in EN, but I guess what you mean is not the homepage (in sense of the start page of that language) but some form of hosting your site on two domains with one being IT and one being EN? Or having IT visitors being redirected to the IT home page and all others to the EN page?

Maybe add a more verbose example of your requirements…

Hint: If languages have their own permalinks they will create language-based sites in their respective folders.

[languages]
  [languages.en]
    baseURL = 'https://example.com'
  [languages.fr]
    baseURL = 'https://example.fr'

This will result in public/en having a full English site and public/fr having the french site. Both with their own home pages.

Thank you,
Your example is for two different domains.
Please, see https://www.nicfab.it
You see that the home page is the same for IT and EN (apart from the posts).
Is it possible to have different home page content (the home page IT with Italian content and the home page EN only with English content)?

That depends on your hosting situation. Typically you add some headers to your system that tell browsers where to go depending on the language of the visitor.

Can it depend on the theme I am using?

That too. Can you post your repository? Do that, it’s easier to debug then.

Unfortunately, I have some issues in pushing the repository on GitHub.
I don’t know.
I hope to solve and post here the link

Here is the repository: https://github.com/nicfab/myhu.git
I use the theme PaperMod: GitHub - adityatelange/hugo-PaperMod: A fast, clean, responsive Hugo theme.

404 not found

Sorry.
It was private,
Now it is public

When you provide a site for others to test, please make sure it builds. This is missing the theme submodule. We should be able to:

git clone --recurse-submodules https://github.com/nicfab/myhu
cd myhu
hugo

I did it

Please see my previous comment.
Your repository is incomplete.

When I do this:

git clone --recurse-submodules https://github.com/nicfab/myhu
cd myhu
hugo

I get this:

WARN 2022/01/14 08:45:51 found no layout file for “HTML” for layout “rss” for kind “page”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2022/01/14 08:45:51 found no layout file for “HTML” for kind “page”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
…
…
…
WARN 2022/01/14 08:45:51 found no layout file for “JSON” for kind “home”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

As a courtesy to those who are trying to help you, please make sure your site builds.

@jmooring I am so sorry.
I don’t know what happened.
I will try again.
Thank you

Probably, I did it.
Here is the repo: GitHub - nicfab/nhugo

Hmm, can you list the URL format you wish to achieve? Something like this:

  • https://domain.tld/en/
  • https://domain.tld/it/

Because when I visit https://www.nicfab.it I am redirected to: https://www.nicfab.it/en/. And if I click the Italian language, I am redirected to https://www.nicfab.it/it/. Both of which, /en/ and /it/ are only showing the content/posts for that particular language.

So, the above is confusing because your current build is working as intended – separate homepages for English and Italian content/posts. (I only see English content/posts in /en/ and only Italian content/posts in /it/.)

Is what you’re asking different themes for /en/ and /it/?

Or, are you talking about the “Welcome to our blog” section? What you want is for the English translation to only show in /en/ and the Italian translation “Benvenuto sul nostro Blog” to only show in /it/?

@nicfab I cloned your repo and built your site. Thank you for that.

You have arranged your content under language subdirectories:

content
├── en/
└── it/

But you have not configured the site to use those subdirectories. See:
https://gohugo.io/content-management/multilingual/#translation-by-content-directory

Change this:

[languages.en]
  title = "NicFab Blog"
  languageName = ":gb: EN"
  languageAltTitle = "English"
  weight = 1
[languages.it]
  title = "NicFab Blog"
  languageName = ":it: IT"
  languageAltTitle = "Italian"
  weight = 2

to this:

[languages.en]
  contentDir = 'content/en/'
  title = "NicFab Blog"
  languageName = ":gb: EN"
  languageAltTitle = "English"
  weight = 1
[languages.it]
  contentDir = 'content/it/'
  title = "NicFab Blog"
  languageName = ":it: IT"
  languageAltTitle = "Italian"
  weight = 2

You can delete content/_index.md — it isn’t used.

The home page for the English portion of your site is content/en/_index.md.

The home page for the Italian portion of your site is content/it/_index.md.

1 Like

@jmooring Thank you very much. I much appreciate it.
I am a lawyer passionate about informatics, and I am not a developer; so, apologies for some of my interventions are not entirely accurate.
Now the architecture of my sites is better.

I understand that I can write inside the file _index.md, which is under content/en or content/it and any additional content is added to the home page.

Moreover, I understand that the central part of the home page (https://www.nicfab.it - where is the disclaimer) depends on the theme used, and it’s impossible to differentiate.

1 Like