Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hugo: how to store images in same directory as a post?

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).

like image 495
user1050755 Avatar asked Oct 15 '25 18:10

user1050755


1 Answers

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.

like image 116
user1050755 Avatar answered Oct 17 '25 23:10

user1050755