---
title: Adding a Jekyll helper script
slug: generate-new-jekyll-post
layout: post
categories: ''
force: false
date: '2018-01-30 00:00:00 +0000'
---

After a month or so of blogging with [Jekyll](https://jekyllrb.com/), I'm very happy with the platform. In particular, I feel that having dived much deeper into its internal workings than I had done before, I expect it to be able to support my pretty basic blogging needs well into the future.

One minor annoyance has been the lack of an easy way to generate new post templates. This is an irritation because having to manually create a new file and manually fill in all the [front matter](https://jekyllrb.com/docs/frontmatter/) values adds friction to a process that should be as fluid as possible.

So today I've added a simple but useful script to my Jenkins repo, which allows a new post to be generated from the command line with minimal effort.

It provides the following interface:

```
Usage: new [options]
    -t, --title TITLE                Title for post
    -s, --slug SLUG                  Slug for post
    -l, --layout LAYOUT              Layout for post
    -c, --category CATEGORY          Add category for post (can be specified multiple times)
    -f, --force                      Overwrite existing file
```

So this command:

```
./bin/new -t "Here's a new post" -s new-post-here -c tutorials -c random
```

generates a new post with an appropriate date and the following front matter:

```
---
title: Here's a new post
slug: new-post-here
layout: post
categories: tutorials random
date: '2018-01-30 00:00:00 +0000'
---

Hello reader...
```

I expect that this will make it even easier to post on this blog! If you could find this useful, it's available [on GitHub](https://github.com/rfwatson/techblog/blob/master/bin/new).
