Keep homepage in subdirectory

Hello everyone, I have been using hugo as my SSG since last year. With the latest update I am having a little trouble with the multi language directory structure. Previously my site was in English and had French and German translation.

What annoys me a little is the redirect from the root of the site to the default language directory no longer exists? all pages for default language are in root site. except content of main sectipn is still as before.

I want my homepage stay back to /host/en/ not redirected to root of host. below my config in hugo

defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true

With that I guess you

  1. did not change anything in your site sources and config and
    upgraded Hugo from version X < 146 and Y > 145
  2. I’m not aware of any changes regarding the handling of defaultContentLanguageInSubdir, so the redirect should still be in site root and ALL content in the subdirectory.
  3. sounds like you have some special layouts that do your things and maybe that behavior has changed.

Educated guess:

  • There was a big change in the handling of the template system in v0.146.0.
  • I guess your problems are cause by your site config and layouts or (theme setup/incompatibilities) with that version

depending of where you come from I would go with a two step update.

  • first update to v0.145.0 and fix all errors, warnings and deprecations to reduce migration noise
  • then to the latest version (v0.147.2 as of today).

For me that would be digging in the dark without your sources.

Nothing special layout in my hugo setup, I upgraded from version 0.130.0 to 0.146.0 there are no critical errors, just a few such as the config on the social site and author site and in the template such as pagination. but it can be resolved immediately. Hugo runnig smoothly and faster, I feel it :slight_smile:

Rendered site before:

/index.html → redirected to default language
/en
/de
/fr

Now, English version of homepage which is default become in root: /index.html and /en/index.html redirected to root as well as all pages in /en/pages/ become /pages/.

Exceptions for main sections like /en/blog/ and remain unchanged, not redirected to /blog Likewise, all blog post URLs have not changed.

If this is a change and default behaviour, is this a way to keep me to stay with previous redirect and structure. where the root / just redirect to default language directory?

I apologize if my question is not in accordance with community ethics, this is the first time I have asked on the forum, previously I always chatted with AI to find a solution.

I will also read the documentation and changelog, but if you are kind enough to give me a recommendation I will be happy to try it out. And sorry I can’t provide repository yet since I’ve only been uploading public directories so far.

I hope you understand that hugo is so popular that even people like me who are just casual users are interested in using it.

all fine, it’s just hard to give detailed recommendations without having sources.

As I said, the behavior has not changed and it is working with a site with NO special stuff like custom layout targeting, permalinks, Url config …

are you using a Theme? If yes - which one and is your version up to date?

give 145 a try (following your estimations that should have no problems.

  • if that works fine, we know that your site source works with the old system
  • fixing warnings, deprecations with 145 gives us a clean start to check out 146+

use latest version

  • I would then go with the latest version - there have been some bug fixes for the new template system in 146.+, that may affect your site.
  • There’s something special, cause blog and pages behave different
    check anything where you mess around with Permalinks, URLs, …

without having more and believing in it works with 145 and no significant warnings/deprecations/errors) I still think that you have stuff in your site that does not work consistently with the new layout system.

You might get some more hints by using

  1. your last working setup hugo version
  2. your used non working hugo version

and post

Please use the same codebase for both runs of:

  • The output of hugo env
  • The output of hugo --logLevel debug

additionally the structure of your layouts folder (incl. filenames) may also give a pointer.
and your hugo.toml

try it out: (with 0.147.2)

git clone --single-branch -b topic-54699-multilingual  https://github.com/irkode/hugo-forum.git topic-54699-multilingual
cd topic-54699-multilingual
hugo or hugo server

Thank you very much for your help, I read the documentation and release notes after 0.130.0 including to follow the recommendations in changed templates structure, I also tried your repo, everything seems fine. my hugo site running well in localhost, but the default language site keep in root site.

Then I change my mind rather than being suspicious, I tried clearing the Hugo cache, the computer cache, and deleting the contents of the public directory.

Then I running Hugo again, trying option to disable fast render. The results was make me relieved . homepage structure is back as before, the root site redirected to default language folder. That’s what I want, and I am sure all the noise is not because of hugo update.

I realize the need to update Hugo for various reasons including security, even though I haven’t fully utilized its new features.

Once again I say thank you, it’s nice to be able to discuss here, even though I’m a beginner. :folded_hands:

1 Like

you’re welcome. glad to hear you got it running.

sry for not telling about public directory…one common pitfall. it’s always good to clean that up, cause hugo just adds nd updates files there. No automatic deletion of old unused files there.