I like to use hugo to process the images to create thumbnails from a main image, the issue is that the filename is pretty gnarly. I usee asset bundle so i have a folder for each blog post.
I had an idea to clean things up a bit by first having an expected filename.
- copy the generated asset from the _gen folder to my current bundle folder, then rename the file.
Since it’s in the bundle location next to the inidex.md file, I should still be able to link to this new file, while not really using the generated file.
The issue is I am unable to copy the file to my current bundle location. Is it possible to copy the file from the _gen to the folder with index.md?
Hugo already has
resources.Copy that can be used to rename resources: Hugo Pipes Introduction | Hugo. I don’t think any manual tinkering should be needed.
_gen dir is for caching, to speed up future builds. There should be no need to copy files from it.
Take a look at Image Processing | Hugo and you will see Hugo can build it all on the fly.
that copy function looks like what I will need.
I will test it out and see.
You don’t need to manually copy the internally used
_gen resources. The resources itself already create the output file using your given filepath.
Here’s how I did for generating favicons files from a list of given assets (from different filename to the required ones):
Line 162 is how I rename the file after image processing.
Line 163 is very important. You need to query the
.Permalink to make it permanent/active/live even-though you’re not using the URL. I remember reading that somewhere in Hugo Pipe specification.
This was the solution, thank you!