-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
tpl/tplimpl: Embedded render hooks fail to get page resource when destination has leading ./ #12514
Comments
With v0.123.0 and later, by default, we don't duplicate resources. See: This is the expected result:
If you change your markdown destination from The issue here is the leading Example site:
Then visit the English version of the test page. |
defaultContentLanguageInSubdir = true
: Processed images not copied to non-default content languages
@bep I'll submit a PR to address this in the render hooks. That seems less invasive than altering the behavior of |
Indeed, using Sorry, I overlooked the v0.123 change („Hugo does not duplicate shared page resources when building the site.“). I did not expect this to be a feature instead of a bug. :-D Pointing this out was really useful: there are two parts on our page with things like |
The markdown bit will be resolved with #12515. But HTML |
Thanks @jmooring . As these are really rare edge-cases where an advanced shortcode makes no sense (mostly some images / videos on the main landing page with a bit of custom markup and classes around), I just created a {{- /*
Get the relative permalink of
1. a resource belonging to the current page's collection, or
2. a global asset (if it does not exist in the current page's collection)
given as the first parameter.
This might be useful since Hugo v0.123.0, which does not duplicate shared
page resources by default with a multilingual, single-host site. For more
details, see https://github.com/gohugoio/hugo/issues/12514 and
https://gohugo.io/content-management/page-resources/#multilingual.
Example:
{{< rawhtml >}}
[...]
<!-- requested file beside the current page or in assets/ -->\
<img src="{{< resourceRelref `foobar.png` >}}">
{{< /rawhtml >}}
*/ -}}
{{- $path := (.Get 0) }}
{{- $resource := default nil -}}
{{- /*
A way to make relative path like "../../foo.png" possible would be
nice but is not supported by this shotcode yet. Ideas welcome to match all
page's resource. Hints:
.Page == the page context from within a shortcode.
$. == root context of the current template(!), not the page.
*/ -}}
{{- with .Page.Resources.Get $path -}}
{{- $resource = . -}}
{{- else -}}
{{- with resources.Get $path -}}
{{- $resource = . -}}
{{- end -}}
{{- end -}}
{{- with $resource -}}
{{- .RelPermalink -}}
{{- else -}}
{{- errorf "[theme] partials/shortcodes/resourceRelref.html: Invalid resource %q in %q (not found in the page's collection nor as global resource in \"assets/\")." $path .Page.File.Path -}}
{{- end -}} So basically like a |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The issue is comparable to #12163 but with languages in sub-dirs. Images with a relative URL in markdown of non-default languages are not copied to the destination subdir.
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes. The issue is reproducible with Hugo >= v0.123.0 up until the current v0.126.1 release. It works with Hugo v0.122.0.
How to reproduce
1. Fresh test site
Created as follows:
Create a
hugo.toml
file with the following content:2. Add a content page with a translation and a
![pic](./image.png)
with
index.de.md
content:and
index.en.md
content:3. Expected result (=Hugo v0.122.0)
public/en/test/image.png
exists when runninghugo server --disableFastRender --cleanDestinationDir --renderToDisk
:4. Actual result (=Hugo >= v0.123.0 up until current release v0.126.1)
public/en/test/image.png
does not exists when runninghugo server --disableFastRender --cleanDestinationDir
:Notice the missing
image.png
belowen/test/
Misc notes / real world example
I ran into this while working on https://foundata.com/en/blog/ (where "de" (German) is the default language and "en" (English) is an additional translation). I added two blog postings and noticed that some images on the English homepage at
/en/
as well as in the blog postings are missing.It worked well with Hugo 0.122.0:
but failed with the latest Hugo version 0.126.1 (Please notice the difference in the "EN" column (especially the
Processed images [...] 0
instead of48
):The text was updated successfully, but these errors were encountered: