CMS & Image upload directory

Netlify CMS stores uploaded images in static.

IIUC image resizing doesn’t work for images stored in static: https://gohugo.io/content-management/image-processing/

Is that right?!

Yep. Hugo image processing only works for files in /content.

And both netlify-cms and forestry.io will only upload files to /static.

I don’t think it would make sense for Hugo to process files in /static, because by definition those files aren’t processed! So you should reach out to the netlify-cms team for a more flexible upload feature (or build it yourself).

Fortunately, Forestry is configurable in this regard - https://forestry.io/blog/how-to-use-hugo-s-image-processing-with-forestry/. It’s not ideal solution, but it works for me.

I think you can work around this by mounting the images in both /static and /assets. See the docs for mount syntax.

1 Like

I’m facing the same issue. I want that users can upload images via the netlify-cms interface (and also see already existing images) but I also want to use image processing functionalities e.g. scaling the images down to save space and bandwidth.

Can anyone share his/her solution/work around?

As @bep said, you can use mounts in your config:

[[module.mounts]]
source = "images"
target = "assets/images"

Are all images visible through the netlify-cms interface this way? And can images be processed this way? Sorry, for my questions. I have a hard time imaging how this works.

Yes, I use this setup with Netlify. In the example above Netflify CMS is set to upload images to assets/images, but thet location could be amything, depends how you have it set up. Yes, once the directory is mounted Hugo can access the images as if they were in /content/images/.

From my Netlify CMS config

backend:
  name: git-gateway
  branch: main
media_folder: assets/images
public_folder: ../images

Netlify CMS has a beta feature that allows relative paths for media uploads for each folder collection. See Beta Features! | Netlify CMS | Open-Source Content Management System