Setting paths for resources in build process

Upon building my site, I noticed Hugo created subfolders for my resized images that reflect the name of the Section and the name of the Bundle itself.

To illustrate what I mean, this is my content structure (under /content):

artikels
├── _index.md
├── accessible-css-defaults
│   ├── default.png
│   └── index.md
├── block-level-links-done-right
│   ├── default.jpg
│   └── index.md

After building, the folder structure looks like this:

artikels
├── accessible-css-defaults
│   ├── artikels
│   │   └── accessible-css-defaults
│   │       ├── default_hue266198f10e8cdad6e17a43f31931518_7867_500x0_resize_box_center.png
│   │       ├── default_hue266198f10e8cdad6e17a43f31931518_7867_500x250_fill_q75_box_center.png
│   │       └── default_hue266198f10e8cdad6e17a43f31931518_7867_8x4_fill_q1_box_center.png
│   ├── default.png
│   └── index.html
├── block-level-links-done-right
│   ├── artikels
│   │   └── block-level-links-done-right
│   │       ├── default_hu54837df629547ca0d108dcc66de67541_122779_500x0_resize_q75_box_center.jpg
│   │       ├── default_hu54837df629547ca0d108dcc66de67541_122779_500x250_fill_q75_box_center.jpg
│   │       └── default_hu54837df629547ca0d108dcc66de67541_122779_8x4_fill_q1_box_center.jpg
│   ├── default.jpg
│   └── index.html

Whereas I’d like it to look like this:

artikels
├── accessible-css-defaults
│   ├── resources
│   │   ├── default_hue266198f10e8cdad6e17a43f31931518_7867_500x0_resize_box_center.png
│   │   ├── default_hue266198f10e8cdad6e17a43f31931518_7867_500x250_fill_q75_box_center.png
│   │   └── default_hue266198f10e8cdad6e17a43f31931518_7867_8x4_fill_q1_box_center.png
│   ├── default.png
│   └── index.html
├── block-level-links-done-right
│   ├── resources
│   │   ├── default_hu54837df629547ca0d108dcc66de67541_122779_500x0_resize_q75_box_center.jpg
│   │   ├── default_hu54837df629547ca0d108dcc66de67541_122779_500x250_fill_q75_box_center.jpg
│   │   └── default_hu54837df629547ca0d108dcc66de67541_122779_8x4_fill_q1_box_center.jpg
│   ├── default.jpg
│   └── index.html

How can I set the name of the output folder for generated bundles? In my example, I’d like it to be simply ‘resources’.

There is no magic here, it is what you see is what you get – so if you want the images inside a folder /resources you need to create a folder with that name and move the images.

Thanks, I understand now. Along the way, I discoverd how to ‘clean up the garbage’ using hugo --gc. It think it would be nice if the garbage collection would be executed by default when running hugo build.

Maybe, but it adds some work (time) to the build, and I wanted to be explicit about it (It deletes files). This will be more obvious as we add more to the “gc” (I deliberately named it generic).

If people want it as a default, they can easily create a alias or similar for their OS.

1 Like