How do I have one folder for each blog post containing all of the assets?

(For reference, here is what my Hugo repository currently looks like: GitHub - ericswpark/ericswpark.github.io: Main website
And a link to the site (latest commit on master branch): https://ericswpark.com)


Right now I have the directory structure set up like this:

content/
  blog/
    2018/
      2018-02-21-sample-post.en.md
      2018-02-21-sample-post.ko.md
static/
  img/
    2018/
      sample-post/
        example.jpg

I am wondering if something like this is possible:

content/
  blog/
    2018/
      sample-post/
        2018-02-21-sample-post.en.md
        2018-02-21-sample-post.ko.md
        example.jpg

Couple of advantages:

  • I can clearly see what asset belongs to which blog post
  • Easier linking? Right now I directly do something like ![example](/img/2018/example.jpg) which feels wrong.

I read through the documentation and found the β€œpage bundles” thing, but the documentation on it is incomplete and from what I can gather the final URL will end up something like the following:

https: ericswpark/blog/2018/sample-post/2018-02-21-sample-post/

But I want it to look like this:

https: ericswpark/blog/2018/2018-02-21-sample-post/

Without manually setting it in the front matter.

Is this possible or should I structure my repository in a different way? Also, if it is possible, how should I β€œcorrectly” import images and other assets within the Markdown files?

With this content structure:

content/
β”œβ”€β”€ blog/
β”‚   └── 2018/
β”‚       └── 2018-02-21-sample-post/
β”‚           β”œβ”€β”€ a.jpg
β”‚           β”œβ”€β”€ index.en.md
β”‚           └── index.ko.md
└── _index.md

The URLs will be:

http://example.org/en/blog/2018/2018-02-21-sample-post/
http://example.org/ko/blog/2018/2018-02-21-sample-post/

See https://gohugo.io/content-management/page-bundles/#leaf-bundles

3 Likes

Thank you so much! It worked.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.