]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugolib: Change duplicate content path warning to an info log
authorJoe Mooring <joe.mooring@veriphor.com>
Thu, 18 Sep 2025 16:03:15 +0000 (09:03 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 20 Sep 2025 18:13:08 +0000 (20:13 +0200)
Improves #13993

hugolib/content_map_test.go
hugolib/language_content_dir_test.go
hugolib/pages_capture.go

index f728621502d889d4d62780661bef6a8ddea20e81..9a22c3c3d97caf84d49142937cc68962a82c5a5c 100644 (file)
@@ -279,9 +279,9 @@ P1: {{ $p1.Title }}|{{ $p1.Params.foo }}|{{ $p1.File.Filename }}|
 `
 
        for range 3 {
-               b := Test(t, files, TestOptWarn())
+               b := Test(t, files, TestOptInfo())
 
-               b.AssertLogContains("WARN  Duplicate content path: \"/p1\"")
+               b.AssertLogContains("INFO  Duplicate content path: \"/p1\"")
 
                // There's multiple content files sharing the same logical path and language.
                // This is a little arbitrary, but we have to pick one and prefer the Markdown version.
index fdcc4cc184676c8446f50750f6b1ea9fc654e7e3..27039400ce6d9272892445798ac20f324b322939 100644 (file)
@@ -175,3 +175,68 @@ title: "p4 theme (nl)"
        b.AssertFileContent("public/de/index.html", `home (de): de: p1 (de)|p2 (en)|p3 (en)|:END`)
        b.AssertFileContent("public/en/index.html", `home (en): en: p1 (en)|p2 (en)|p3 (en)|:END`)
 }
+
+// Issue 13993
+func TestIssue13993(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['home','rss','section','sitemap','taxonomy','term']
+printPathWarnings = true
+
+defaultContentLanguage = 'en'
+defaultContentLanguageInSubdir = true
+
+[languages.en]
+contentDir = "content/en"
+weight = 1
+
+[languages.es]
+contentDir = "content/es"
+weight = 2
+
+# Default content mounts
+
+[[module.mounts]]
+source = "content/en"
+target = "content"
+lang = "en"
+
+[[module.mounts]]
+source = "content/es"
+target = "content"
+lang = "es"
+
+# Populate the missing es content with en content
+
+[[module.mounts]]
+source = "content/en"
+target = "content"
+lang = "es"
+-- layouts/all.html --
+{{ .Title }}
+-- content/en/p1.md --
+---
+title: p1 (en)
+---
+-- content/en/p2.md --
+---
+title: p2 (en)
+---
+-- content/es/p1.md --
+---
+title: p1 (es)
+---
+`
+
+       b := Test(t, files, TestOptInfo())
+
+       b.AssertFileExists("public/en/p1/index.html", true)
+       b.AssertFileExists("public/en/p2/index.html", true)
+       b.AssertFileExists("public/es/p1/index.html", true)
+       b.AssertFileExists("public/es/p2/index.html", true)
+
+       b.AssertLogContains("INFO  Duplicate")
+       b.AssertLogContains("! WARN  Duplicate")
+}
index 37ed3c89ca0e90c932299a9a028ae8e11fd85f75..91f3afae4fbd002360d74678a0b1f2dd33d1af19 100644 (file)
@@ -334,7 +334,7 @@ func (c *pagesCollector) collectDirDir(path string, root hugofs.FileMetaInfo, in
                        baseLang := hstrings.Strings2{pi.Base(), meta.Lang}
                        if fi2, ok := seen[baseLang]; ok {
                                if c.h.Configs.Base.PrintPathWarnings && !c.h.isRebuild() {
-                                       c.logger.Warnf("Duplicate content path: %q file: %q file: %q", pi.Base(), fi2.Meta().Filename, meta.Filename)
+                                       c.logger.Infof("Duplicate content path: %q file: %q file: %q", pi.Base(), fi2.Meta().Filename, meta.Filename)
                                }
                                continue
                        }