Picture path handling by post

Hey community,
i just started building my first page with hugo. The framework is now in place, and I want to write first posts. Since I will have a lot of pictures in my posts I thought of the following solution:

  • With the creation of a new post via hugo new <section>/<postname>.md a new folder: /static/images/<postname> should be created
  • In the new post, a image path to that folder should be pre set, so that all images in the created folder can be accessed via their names.

I’ve read the Page Resources, Image Processing, Front matter, Archetype and Content Organization pages, but I’m non the wiser…

Is there a possibility doing that with archetypes and frontmatter?

thanks!
audiophiel

I think what you want is in the work but not there yet: https://github.com/gohugoio/hugo/issues/4535

Thanks! as long there is no way to do this automatically, is there a front matter command to set a graphics path for the current document? I would just to it by hand (or via bash) until hugo supports this very useful feature.

Thanks!
audiophiel

I’m not sure what you mean by graphic paths. But i’m Pretty sure you can add comments to your achetypes with instructions to your editors.

I mean a command, that says hugo “okay, whenever in this document scr=’.jpg’ is used, the file .jpg lies in this folder” like you can set \graphicspath{/path/to/img/folder} in LaTeX. Did this make things clearer?

Using the example above, you can simply bundle the images with your posts. This means adopting a structure like this: hugo new <section>/<postname>/index.md

Then just place the images in the <postname> folder, alongside index.md. No need to set any image paths in the markdown, just the file name ![](my_pic.jpg).