I’ve never really touched
rake before, but since switching to Jekyll I’m finding that it’s becoming an essential part of my workflow. In the limited area of blogging, at least.
rake is a version of
make in which you define all your targets in Ruby. Because practically anything would be an improvement over
Makefile syntax, this is pretty easy to work with. I’m not a huge fan of shell scripting at the best of times, so mixing it in with something else is… not desirable. I still find Ruby less intuitive than Python, but that’s my prejudices talking.
To elaborate… what does posting a new entry look like for me?
rake serverto start up an automatically-rebuilding local webserver copy of my blog
rake post[raking-jekyll]to make a new post with the YAML front matter boilerplate
- Actually edit the newly created post in an editor
rake deployto rsync the local copy to my hosting over ssh
Any part of my routine which looks like it might be scriptable has been replaced with a
rake target. For example, the
- Copies a template file
- Names it according to the current date and provided title
- Adds an expanded version of the current date into its YAML front matter so sorting will work correctly if I post multiple times a day
Since I rarely know the current date without having to look it up, that certainly saves me some effort.
Here’s my Rakefile, if you want to use anything from it. It’s probably not properly idiomatic Ruby, but it does at least work.