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

resources.Copy silently fails with page resources #10584

Open
jmooring opened this issue Dec 26, 2022 · 0 comments
Open

resources.Copy silently fails with page resources #10584

jmooring opened this issue Dec 26, 2022 · 0 comments
Labels
Milestone

Comments

@jmooring
Copy link
Member

jmooring commented Dec 26, 2022

This works:

{{ with resources.Get "a.jpg" }}
  {{ with . | resources.Copy "b.jpg" }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ end }}

This silently fails:

{{ with .Resources.Get "a.jpg" }}
  {{ with . | resources.Copy "b.jpg" }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ end }}

Reference:
https://discourse.gohugo.io/t/copying-a-resource-in-page-bundles/42077/2


Here's a trick to get this to work... call the Publish method. Seems that .RelPermalink isn't publish the resource.

{{ with .Resources.Get "a.jpg" }}
  {{ with . | resources.Copy "b.jpg" }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
    {{ .Publish }}
  {{ end }}
{{ end }}
@jmooring jmooring changed the title Improve resources.Copy or create .Resources.Copy, or both Improve resources.Copy Nov 25, 2023
@jmooring jmooring changed the title Improve resources.Copy resources.Copy silently fails with page resources Mar 26, 2024
@bep bep added this to the v0.131.0 milestone Jul 22, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
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