Post asset folder

Hello.I just tried to migrate from hexo to hugo.

However,there is something wrong with the asset of each post.I went through https://github.com/gohugoio/hugo/issues/1768 , but I still feel confused.

Hexo: there is a config called post_asset_folder ,it allows each post has its own asset folder (folder name is same as post title).
for example:

├─test_title.md
└─test_title
    ├─a.png
    ├─b.jpg
    └─c.pdf

then,I can add images to test_title.md with a relative path:

![image a](./test_title/a.png)

then I can preview it locally with vscode.and all the images are in seperate folder.


Hugo: I find that all the images should be in the static folder. for example:

├─archetypes
├─content
    ├─test_title.md
├─data
├─layouts
├─static
    ├─a.png
└─themes

in the test_title.md the link looks like:

![image a](/a.png)

I can only preview it using “hugo server” with the browser. and it is hard to keep all the images well organized,unless i create a similar folder tree in the static folder.


By the way there is another small program:

I use git to manage my notes. when using hexo I can new a site and clone my note into _posts dir and it is done.

when using the hugo.if i clone my notes into content folder,the images will not show as expected.

either I create a new repo containing the hugo dir(content,staic…etc) and fix the image links. or I create a new repo to manage all the images and fix the image links.


So,is there a way to work aroud with the post asset folder?
or is it possible to add such feature?

@misaka,

So,is there a way to work aroud with the post asset folder?
or is it possible to add such feature?

The behavior you described already exists

I think an understanding of hugo’s page bundles would be what you’re looking for.

1 Like

thank you very much. I think the doc is kinda misguiding .(or probably it is just my problam.) After some searching I figured it out.

I will write it down here .

when you new a post
hugo new test.md
hugo will create “test.md” with title: "test" in the content folder.

├─content
   ├─test.md

if you want to use page bundle (the leaf branch).

├─content
   ├─test
      └─index.md
      ├─a.jpg
      └─b.pdf
  1. create a folder named test
  2. rename test.md to index.md
  3. mv index.md into test folder
  4. import the bundles using relative path: ![image a](a.jpg)

maybe this will be more specific.

thank you anyway.

1 Like

You’re most welcome @misaka

I’m looking for the solution about asset folder too, I also found the solution about hugo's page bundles, but it is really annoying when find file by file name, since every file is index.md.

So is there any way to solve this problem without change the file name?

And I’d prefer the the architecture like

├─content
   ├─test.md
   ├─test
      └─a.jpg
      ├─b.jpg
      └─c.pdf

What you want is not possible. Please create a new topic if you have additional questions.