Extending 'new content' to create new media directories

I’d like to submit my feature for creating a media folder when you create new content (of course with a flag) I’ve found when I’ve created a content file I always have an image: somewhere in the file and that I point the path to: static/media/images/myContentRootName/nameOfContentFile (the Base media directory can also be pulled from a config) So I extended the hugo/new.go at master · gohugoio/hugo ( to include the media directory initalization when I create new content, is this something that would be accepted if I sent in a merge request or is this too specific of a use case to be unwanted?

I feel that this is very specific, but I also don’t quite get what you have done :wink: so maybe a bit more explanation would help to have an opinion. I see that you have an md-file in the static directory and think that’s not something Hugo wants to do. but maybe you were trying to write .jpg?

Sorry I don’t know why I put it as a file, yes.

Basically when I create a new content file hugo new content/ That also creates a directory with the same pathing in the static path. static/content/mycontent/ so that I don’t have to go and set up a bunch of folders to add a structured file to my site.

It seems like using Page Bundles would be easier to manage.

Instead of:

hugo new post/


hugo new post/foo/

That creates this structure:

└── post
    └── foo

Then I can place the images parallel to the markdown:

└── post
    └── foo
        ├── kittens.jpg
        └── puppies.jpg

In addition to keeping all of the files related to this page in one place, this approach exposes the images as Page Resources, making them available for Image Processing including resizing and filters.

1 Like