When I run the command hugo --printPathWarnings
I get WARN Duplicate target paths: /image/thumbnail.jpg (2)
. Does Hugo have a way to pinpoint the culprit files? Searching with VS Code returns nil. The thumbnail is a fallback image in the assets folder.
No, but I’m guessing you have one (also) in /static.
There is no duplicate image in static. But here is a reproducible test site. Check the header and footer partials. The image is in the assets folder. The header calls the image for open tags and the footer calls the image for JSON schema. Running hugo --printPathWarnings
generates the warning WARN Duplicate target paths: /image/thumbnail.jpg (2)
.
The warning is correct, if that’s what you’re asking.
Why it is coming up? Or did anything change in recent versions? I don’t remember this happening before.
dunno if there have been any changes in resource caching for pages. Tried with 0.140.0 and 0.120.1 and the warning is there.
You have two partials that call .Permalink
for the image.
according to the docs, .Permalink not only generates the link but also publishes.
@bep?
Calling.Permalink
twice within the same partial does not raise the warning. Even not with two calls toresources.GetMatch
using differen variables.
Using a page resource also won’t complain even in different partials.Looks like there’s a _caching mechanism for resources rooted at the partial. and somehow related to the type (global/page)
You could avoid that by saving the image to a page.Store and retrieve it later
head.html
{{- $img := resources.GetMatch "image/thumbnail.*" }}
<meta property="og:image" content="{{ $img.Permalink }}">
<meta property="og:image:type" content="{{ $img.MediaType.Type }}">
<meta property="og:image:width" content="{{ $img.Width }}">
<meta property="og:image:height" content="{{ $img.Height }}">
{{- $.Store.Set "Thumb" $img -}}
footer.html
{{- with $img := $.Store.Get "Thumb" -}}
...
"image" ( dict
"@type" "ImageObject"
"url" $img.Permalink
...
{{- end -}
OK, I’m guessing that there’s a synchronisation issue that makes Hugo write the same file twice to disk (I checked, and it’s not a caching issue) which provides a “false warning” which you should ignore for now.
The “warning detector” just counts files written to disk, so that’s correct (it doesn’t know why).
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.