Jekyll has introduced something called collections (beta at the time of writing) which has been added to handle custom post/page types.
The usual example is for a website that wants a blog and also a portfolio. The portfolio can be handled with collections.
Overall it works really well, but I did run into a few issues while setting it up against Jekyll 2.5.2. I thought I’d write these things down here to save myself and maybe others’ time.
Firstly, in the Jekyll’s _config.yml
, I had some issues around the permalink. I initially set it to /work/:year/:title
but for some reason :year
just isn’t working. I removed that section and still had odd problems. It turns out you have to include a slash at the end otherwise it gets confused about the output format. I ended up setting it to this: permalink: /work/:title/
.
Second thing was around sorting. I wanted the collection items to be sorted descending by date. Using the sort | reverse
in the for loop didn’t work. Apparently, you cannot sort inside the for statement, who knew. This is how I did what I needed:
Jekyll is awesome for managing static sites. I’ve used it on a few sites, including this one. If you haven’t tried it yet, you really should.