-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Allow .Resource.Get etc. to also work with the original path/name #10096
Comments
The docs here: Indicate that the |
I have updated the docs sightly (the
It was certainly the prime motivation behind the "rename feature" as it allows having a generic template work without having to rename any images. We may consider making both work (somehow), but for now I suggest you don't rename your resources. There is a |
I hope that even after renaming, the The reason is as follows: I have referenced the image |
It's not terribly pretty, but you can get a renamed page resource within render hook with something like:
This issue is essentially about using the resource |
I would also like to see this fixed, my use case is that I have images in a format not recognized by Hugo (yet), JXL and generate JPEG derivates which are located in a subdirectory. What I'm doing currently is get the image by name, check the MediaType (which is configured base on extension) and if it's JXL try to load another image from a known location, like And actually I can't really understand why this hasn't been implemented in the first place. Maybe it's easier to add a |
Working around this by trying to access the required file from the parent isn't working as well:
Where But that this approach isn't working is certainly related to #11439. |
This will be addressed with #11940 |
Fixed with #11940. |
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. |
Normally, one can use
.Resource.Get "images/test.png"
to retrieve a page bundle resource. But if one gives the resource a name in the frontmatter like so:Then the above function will fail. It will work however if the path is replaced by the name:
.Resource.Get "header"
but that is neither expected behavior (certainly not documented) nor does it follow from the documentation of Page Resources in the frontmatter where it suggests using.Resources.GetMatch
.This Hugo forum post also describes this and provides a repo to test it.
https://discourse.gohugo.io/t/function-partial-that-loads-image-breaks-when-page-resource-is-given-a-name/39486
https://github.com/anakinsleftleg/hugo_plain/tree/help1/pageresourcemetadata/main
I would expect that the path would ALWAYS work, and the name will only work if defined of course.
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
The text was updated successfully, but these errors were encountered: