Using resource.Copy to get a physical copy of remote file

Related to v 0.100.0 release. While this works

{{ $bar := resources.GetRemote "https://example.org/foo.js" | resources.Copy "js/bar.js" }}

Is it possible to use the same to get the physical file copied to the same folder (assets/js/foo.js)?

No, that’s not possible (at least not via Hugo).

The remote file will be cached to disk, though.

I think I misunderstood then what resources.Copy does.

We had a discussion about the naming, and it’s probably most useful for renaming as in: Give it a new URL. But it’s technically a copy with a new name.

I have a case where a build fails few times on CloudFlare Pages due to delay in fetching a remote JS file using resources.GetRemote. So, thought resources.Copy does indeed ‘copy’ a file from remote. For now, I went back to copying the file manually every time it is updated (which is frequently, like 2-3 times a week!). But I have a few use cases where this feature will be useful.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.