4

To have a cleaner layout, I want each of my posts to reside in its own directory along with all required assets like images and the like. Is this possible with hugo or any similar tool? If so, how?

The problem is that files alongside each post don't get copied into the same www export directory as the corresponding post's html file (or, alternatively, image urls reconstructed using the proper final location).

Jakub Kukul
  • 12,032
  • 3
  • 54
  • 53
user1050755
  • 11,218
  • 4
  • 45
  • 56
  • 1
    Each tool handles this sort of thing slightly differently. I would suggest editing your question to only address one tool. What have you tries? What doesn't work about it – Waylan Jan 17 '19 at 21:12
  • As per @Waylan's suggestion, I edited your question to only address Hugo. A similar question for Jekyll already exists [here](https://stackoverflow.com/questions/10363812/local-post-assets-with-jekyll). – Jakub Kukul Feb 19 '19 at 04:26

1 Answers1

5

I found a solution for Hugo.

Front matter (omit url):

---
author: abc
date: 2019-01-14 21:23:43+00:00
draft: false
title: 'bla'
type: post
---

Markdown post file is an index file now:

hugo new 2019-01-14-your-post-title/index.md

That way you won't have /2019/01/14/your-post-title urls, you get /2019-01-14-your-post-title/ instead, which is fine by me. Now you can put images into content/2019-01-14-your-post-title/ and reference them from the markdown index.md file directly without using any paths or having to store them in a central location first.

user1050755
  • 11,218
  • 4
  • 45
  • 56