URI: 
       Add config option disableDefaultLanguageRedirect - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 75ad9cdaaba5e2c13582cd95bc77fb1b570e0b75
   DIR parent e293e7ca6dcc34cded7eb90a644b5c720c2179cf
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Thu, 12 Dec 2024 15:42:17 +0100
       
       Add config option disableDefaultLanguageRedirect
       
       Fixes #13133
       
       Diffstat:
         M config/allconfig/allconfig.go       |       3 +++
         M hugolib/config_test.go              |      23 +++++++++++++++++++++++
         M hugolib/site_render.go              |       3 +++
       
       3 files changed, 29 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go
       @@ -505,6 +505,9 @@ type RootConfig struct {
                // Set this to true to put all languages below their language ID.
                DefaultContentLanguageInSubdir bool
        
       +        // Disable generation of redirect to the default language when DefaultContentLanguageInSubdir is enabled.
       +        DisableDefaultLanguageRedirect bool
       +
                // Disable creation of alias redirect pages.
                DisableAliases bool
        
   DIR diff --git a/hugolib/config_test.go b/hugolib/config_test.go
       @@ -1339,6 +1339,29 @@ Home.
                b.Assert(len(b.H.Sites), qt.Equals, 1)
        }
        
       +func TestDisableDefaultLanguageRedirect(t *testing.T) {
       +        t.Parallel()
       +
       +        files := `
       +-- hugo.toml --
       +defaultContentLanguageInSubdir = true
       +disableDefaultLanguageRedirect = true
       +[languages]
       +[languages.en]
       +title = "English Title"
       +[languages.sv]
       +title = "Swedish Title"
       +-- layouts/index.html --
       +Home.
       +
       +
       +`
       +        b := Test(t, files)
       +
       +        b.Assert(len(b.H.Sites), qt.Equals, 2)
       +        b.AssertFileExists("public/index.html", false)
       +}
       +
        func TestLoadConfigYamlEnvVar(t *testing.T) {
                defaultEnv := []string{`HUGO_OUTPUTS=home: ['json']`}
        
   DIR diff --git a/hugolib/site_render.go b/hugolib/site_render.go
       @@ -334,6 +334,9 @@ func (s *Site) renderAliases() error {
        // renderMainLanguageRedirect creates a redirect to the main language home,
        // depending on if it lives in sub folder (e.g. /en) or not.
        func (s *Site) renderMainLanguageRedirect() error {
       +        if s.conf.DisableDefaultLanguageRedirect {
       +                return nil
       +        }
                if s.h.Conf.IsMultihost() || !(s.h.Conf.DefaultContentLanguageInSubdir() || s.h.Conf.IsMultilingual()) {
                        // No need for a redirect
                        return nil