Convert a directory of blog posts to individual folders

I’ve recently converted my Middleman blog over to Hugo, which was much easier than I expected. I’m not a developer, and I’m brand new to Hugo, and jumped in by building my own theme.

My question: Do I need to convert each blog post into a folder with an index file in order to take advantage of image processing, listing an image from Frontmatter while in the list view, etc? (using Page Resources)

I’m currently using the images array in Frontmatter to populate OG tags, and I was hoping I could use the first image from that list as my “Featured Image” on the list pages — but those all map to the static folder right now.

I’ve got ~80 or so posts, which will take me a bit to convert, but it would be worth it if I could take advantage of some smarter image controls.

Thanks so much for your help! The forum has been a HUGE help thus far!

I believe you will need to convert. But you might be able to create a headless page bundle to hold your media and that might work. I’m mentioning it to inspire you to look at how others have done it; I haven’t done it myself. :slight_smile:

Thanks so much for the push! I’ll start down that road. :sweat_smile:

I cobbled together a script that converts a directory of files into folders based on the file names, and then moves the file into the folder, and changes the name to

for file in *; do if [[ -f "$file" ]]; then mkdir "${file%.*}"; mv "$file" "${file%.*}/"; fi; done

Be mindful that any “” files will also get moved and renamed.

I hope this is helpful to anyone else that might have a directory full of blog posts that needs converted to a directory full of folders based on the post file name.


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