Metadata and assets vs page resources

Hello,

I am trying to work on something that could be called a photo gallery.
my input assets are high-resolution images to which I add metadata (title, description, material, …)
I don’t want to publish the high-resolution images to /public, only resized images.

At first I

  • added the images as Resources in a page leaf bundle
  • resized the images in the layout using hugo pipes
  • added metadata about the images under [[resources]] in the front matter

This worked very well except that the original image gets published in /public. This has already been discussed on the forum and it seems the only way to remove these images in /public would be a post-processing step to remove then.

Then I realized that resources in /assets do not get the same treatment. Only the resized version that are called by their respective .RelPermalink are written to /public.

I would prefer not to add a post-processing step after the /public directory is created so i am considering the move of all my images to /assets, but now where should I put the metadata describing the images ?

I would greatly appreciate your feeback if you have found an elegant solution to this.

Have you tried this?

1 Like

Thank you sephore for pointing me in thie direction

strangely, it did not work when I added the

[build]   
  publishResources = false

to config.toml as mentioned in Easy way to serve responsive images with Hugo

but it did work when I added

[_build]
  publishResources = false

(with an underscore as mentioned in https://gohugo.io/content-management/build-options/) to the index.html of my leaf bundle page

do you have an idea of what is the correct way of handling this and why the answer you pointed seems different than the documentation ?

The documentation is correct, “_build”.

2 Likes

As a follow up it works perfectly thank you !

I managed to have just one definition in the top photo section of my hugo site by adding to the front matter (toml) :

[cascade._build]
    publishResources = false

my public folder went from 200MB to 2MB :slight_smile:

4 Likes

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