Where should images go?

From reading about hugo it seems like images can either go in /static/images or in a page bundle with the content. Is that right? If so is there any guidance on which method is better? Pros/cons?

If I have an about page with some images, should I do:

/content/about/index.md
/content/about/image1.jpg

or

/content/about.md
/static/img/image1.jpg

If I have dozens of a specific type, say books, with a content page for each book and I want a picture of the cover of the book should that be:

/content/books/book-one/index.md
/content/books/book-one/cover.jpg
/content/books/book-two/index.md
/content/books/book-two/cover.jpg
etc.

or

/content/books/book-one.md
/content/books/book-two.md
/static/img/book-one-cover.jpg
/static/img/book-two-cover.jpg

Trying to understand the best practices

I did find this older thread Discussion: Content Organization Best Practice which weighs both options. It seemed like it was user preference with pro/cons on both sides, although in the very last post before the thread was closed, @alexandros, who seemed like he originally preferred having images in the static folder,
said:

Page Bundles and image processing is the way forward to proper content management.

So it sounds like grouping images and content together in page bundles is now the preferred method, am I understanding that correctly?

It is the simplest way to manage images in a Hugo project.

If for some reason, you need to have them in a separate folder -like for example for Forestry or some other service- images will need to reside under the assetDir so that you can get them as resources on the fly with the method resources.Get

1 Like

I think so, too.

This is what I prefer:

/content/books/book-one.md
# or
/content/books/book-one/index.md

but

/content/books/book-two/index.md
/content/books/book-two/cover.jpg

When these files are in /content/ you can use Page Resources and Image Precessing out of the box.

For blogging/time-critical contents I use

/content/blog/2020-12-25-my-post/index.md
/content/blog/2020-12-25-my-post/image.jpg
/content/blog/2020-12-25-my-post/pdf-file.pdf
1 Like