Excluding original photos from Page Resources from Compiling in public folder

Hello!

I have a shortcode that resizes and compress images. My images related to each post are inside the content/post/ folder. When I compile the site, it generates all the compressed versions for the images, but it also saves the original image in the public folder. Is there a way to exclude them?

Not that I know of (and I saw this question more than once already in this forum).

I think what I would do if I had this issue would be to rename the resized and compressed images so that I can exclude them after compilation with a helper-script that deletes “every image except”. Like

imagename.jpg << deleted
imagename-resized-100x200.jpg << not deleted
imagename-comp-resized-100x200.jpg << not deleted
1 Like

I will try that, Thank you!

A solution to this problem was given to me in Metadata and assets vs page resources so I thought it could help others who find this question.

A _build option was added that can be used to avoid any automatic publishing of page level resources. cf https://gohugo.io/content-management/build-options/

This can be used to exclude the original photos from Page Resources from Compiling in the public folder.

1 Like

Thank you!