Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False path warning / resources possibly written twice to /public in some cases #13164

Open
bep opened this issue Dec 18, 2024 · 1 comment
Open
Assignees
Labels
Milestone

Comments

@bep
Copy link
Member

bep commented Dec 18, 2024

See https://discourse.gohugo.io/t/duplicate-target-paths/52788/5

@bep bep added the Bug label Dec 18, 2024
@bep bep added this to the v0.141.0 milestone Dec 18, 2024
@bep bep self-assigned this Dec 18, 2024
@jmooring
Copy link
Member

FYI...

With only 1 file (foo.txt) in the assets directory, this template...

A: {{ (resources.Get "foo.txt").RelPermalink }}
B: {{ (resources.GetMatch "foo.txt").RelPermalink }}
C: {{ (index (resources.Match "foo.txt") 0).RelPermalink }}
D: {{ (index (resources.ByType "text") 0).RelPermalink }}

...triggers this warning:

WARN  Duplicate target paths: /foo.txt (4)

But this template doesn't trigger any warnings:

A: {{ (resources.Get "foo.txt").RelPermalink }}
B: {{ (resources.Get "foo.txt").RelPermalink }}
C: {{ (resources.Get "foo.txt").RelPermalink }}
D: {{ (resources.Get "foo.txt").RelPermalink }}

I tried to create an integration test but I couldn't trigger the warning.

integration test
func TestFoo(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
printPathWarnings = true
-- assets/foo.txt --
foo
-- layouts/index.html --
A: {{ (resources.Get "foo.txt").RelPermalink }}
B: {{ (resources.GetMatch "foo.txt").RelPermalink }}
C: {{ (index (resources.Match "foo.txt") 0).RelPermalink }}
D: {{ (index (resources.ByType "text") 0).RelPermalink }}
-- layouts/unused/single.html --
{{ .Title }}
`
	b := hugolib.Test(t, files)

	b.AssertFileContent("public/index.html",
		"A: /foo.txt",
		"B: /foo.txt",
		"C: /foo.txt",
		"D: /foo.txt",
	)
	b.AssertLogContains("WARN  Duplicate target paths: /foo.txt (4)")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants