Keep images & content together


#1

It would be really nice to be able to keep images associated with some content in the same folder as that content, instead of having to keep them “Far away” in the static folder.


#2

Old thread: https://groups.google.com/forum/#!searchin/hugo-discuss/images/hugo-discuss/MMNfUz_UHOg/dccqpX3o5J0J


#3

Here’s some more discussion as well: https://github.com/spf13/hugo/issues/147


#4

Thanks for the link to the github repo.

We’re going to try to keep as much discussion here as possible, rather than on github, since it’s so much nicer here, but it’s definitely good to have a link to what was said over there.


#5

Please please please make this happen. I’ve been blogging with nanoc for a while, and a home grown static site generator before that. Both allowed you to keep images next to your text.


#6

This morning i came across TextBundle (spec). A few Markdown editors on the Mac already support it, with more coming.

It would seem to solve the issue of keeping the Markdown and assets together in a way that an increasing number of editors would support natively.

It also looks like it supports additional information to be stored allowing Hugo-specific commands to process the assets as some people in the github ticket wanted.


#7

I would say this will happen, and soon, @spf13? Maybe a good candidate for 0.14.

In it’s first form - I guess what people (me included) ask for is that “unknown content types” (those with no content handler in Hugo) will be synced just as they would be if placed in /static.

This would solve the 90% requirement.


#8

Yes. I think this is a good candidate for 0.14

It’s not super hard to code, but it’s really hard to get everything right. Once we release this a lot of people will depend on it and it will be pretty hard to change.

This is primarily why it’s taking some time.


#9

This is really necessary for large documentation projects. It is much easier for contributors to see the images relative to the directory in which they appear. For example:

/registry
   content.md
   content2.md
   /images
      image1.jpg
      ...
      image3.jpg

We have a large documentation project and the files live in multiple repositories as well as act as content for our official documentation. Our programmers want to ensure that documentation “works” in Github too; this would support that.


#10

[quote=“moxiegirl, post:9, topic:51, full:true”]
This is really necessary for large documentation projects. It is much easier for contributors to see the images relative to the directory in which they appear. [/quote]

To me the way it’s done in Nikola is even better, iow.

../content/post
    foo.md
    foo/fooImage-1.jpg
    ...
    foo/fooImage-n.jpg
    bar.md
    bar/barImage-1.jpg
    ...
    bar/barImage-n.jpg

#11

So, in the source material, you are requiring a separate subdirectory to house the images? That seems like it would create a lot of subdirectories to house images — as opposed to a single images directory.


#12

moxiegirl discuss@gohugo.io writes:

So, in the source material, you are requiring a separate subdirectory to
house the images? That seems like it would create a lot of subdirectories
to house images — as opposed to a single images directory.

Well, the point is that you do not require having separate subdirectory for
each post, but you can have it.

There is also possibility - in Nikola - to have them all in a single 'images’
directory, but then I have to take care to properly name all those images
instead of simply have them in appropriate subdirectory.

For me, subdirectory/post is better option.

Sincerely,
Gour


#13

+1 to this. I write a log of blog posts that are “how-to” posts which include screenshots. I can see how this could get really challenging really quickly with having to keep the images separate, although I can see how the “subdirectory for each post” would be a workaround. Definitely challenging.


#14

After some pause I do resume with Hugo, but wonder if this feature make it for 0.14? What about 0.15?


#15

Partly in 0.14. You can have media files in /content, so it’s possible to group images and content in the same folder, but there are more work in this department.

Not much have happened in this department for 0.15, other than an important performance fix.


#16

my structure:

/post/article-name/index.md  (article markup, converted to index.html)
/post/article-name/my-image.jpg
/post/article-name/other-image.png

#17

What is your SRC for images(-shortcode) in this setting?


#18

This would also be my question.
I want to save images next to md files for management purposes. I also want show the whole content - with images - on both list pages, as well as the article pages.

I could not figure out how to import the path + slug of the article into the ‘figure’ shortcode in a way that would work on list pages like the blog frontpage.

Any ideas?


#19

is there any progress being made on this ? I’m new to Hugo and I just tried a few different settings trying to keep my content and images in the same folder. so far, my end result just put the image under /public/post/folder_name/nameimage.jpg and the html file under /public/year/month/folder_name/index.html


#20

any update for this requirement?
i try HUGO 0.17, the content and images still need to be separate