mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-24 04:45:04 -04:00
hugolib: Change duplicate content path warning to an info log
Improves #13993
This commit is contained in:
parent
1140314be1
commit
64f40731f1
@ -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.
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user