From b6c5e4c59d9f548f7496ea7331470afe57cc603d Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Tue, 30 Jan 2018 15:00:53 +0000 Subject: [PATCH] Add jekyll helper post --- _posts/2018-01-30-generate-new-jekyll-post.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 _posts/2018-01-30-generate-new-jekyll-post.md diff --git a/_posts/2018-01-30-generate-new-jekyll-post.md b/_posts/2018-01-30-generate-new-jekyll-post.md new file mode 100644 index 0000000..5bf4e68 --- /dev/null +++ b/_posts/2018-01-30-generate-new-jekyll-post.md @@ -0,0 +1,47 @@ +--- +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).