I’m looking at converting jameshfisher.com from Jekyll to Hugo, and have run into a problem.
Jekyll extracts info from post filenames. Specifically, my files are at _posts/:year-:month-:day-:slug.md, and this is used to render the file _site/:year/:month/:day/:slug/index.html. This feature is a must for me, since I need exactly the same post URLs as before, and I don’t want to re-work hundreds of old posts.
It seems Hugo doesn’t do this by default. How do I turn on support for this? I can see this GitHub issue which suggests … it’s not supported? If not, I’m willing to do some work to enable it, but I’ll need some pointers.
Just wanted to let you know that this has been implemented somewhere before 0.38.2:
You can use the :filename option to the frontmatter > date setting in your config
Sorry, yes. An example post front-matter is:
—
author: playpen_admin
date: 1994-12-07 09:57:14+00:00
draft: false
title: Antirom CD-ROM (1994)
type: post
url: /1994/12/antirom/
categories:
- Portfolio
tags:
- antirom
- Interactive
- Interactivity
—
My config.toml has:
[frontmatter]
date = [":filename", ":default"]
and permalinks:
[permalinks]
posts = “:year/:month/:title/”
My blog is based on a modified version of the whisper theme, so the posts folder takes this structure:
-- blog
-- _index.md
-- 1994-12-07-antirom.markdown
etc.
I noticed a few posts had exported from WP with a slug, which I thought was interfering. They’re gone now. But all of them have a url param in the front matter. Without the URL param, a filename called 1994-12-07-antirom.markdown still ends up as sitename.com/antirom and I was hoping to just use the filename instead of having the param in the front matter.
It may be that the only way to properly do it is either with slug/url or to have the files organised in year/month/day format (which is even more of a hassle).