Forcing a Jekyll Update on Heroku
As I said before, deferring a hosted Jekyll post by specifying a date stamp in the YAML front-matter does not mean that the post will magically appear when the timestamp is “satisfied.” You have to “tickle” the host - in my case, Heroku.
Posts Won’t Publish Themselves
The only documented way to trigger the Jekyll buildpack is to push to your Heroku repo. Of course, at the time that you want to publish,
- You’ve probably already finished all of your writing awhile (days!) ago, and
 - It’s probably the middle of the day, and you’re on to other stuff, so you want a “fire and forget” solution that doesn’t require a lot of input from you.
 
Creating a No-Content Git Commit
Turns out that Git supports an almost-no-effort, no-content publish.  git push with no committed changes is a no-op.  But you can create an “empty,” pushable commit by running:
git commit --allow-empty -m "Commit message"
Forcing Publication
So, my “deferred-posting” workflow is…
- Push your post into the 
_postsdirectory, complete with thedateentry in the YAML front-matter to defer its publication. - Some time after publication 
date, do something to create an “empty” commit and push it to Heroku. 
My “Update the Slug” Script
I’ve created a shell script to do the basics of creating an empty commit in a specified git repo and pushing it to Heroku. I keep it in my Github dotfiles repo; the script itself is here. It probably could be bulletproofed a bit; I’d love to get pull requests for improvements!
Triggering the Script
There are a lot of ways to trigger the script; I currently use an ifttt recipe to ultimately force Hazel (on my home Mac server) to run it:
- I use Siri on iOS to add a Reminder to my Blog reminders list.
 - That Reminder triggers ifttt to drop a particular file, with a particular name, in my Dropbox folder.
 - Hazel detects that file in that location, and triggers the shell script.
 - The shell script creates an empty commit and pushes it to Heroku.
 - Heroku generates a new slug, forcing the Jekyll blog to update itself.
 
Other Triggers
I’m considering other approaches (mostly based on git pre-commit hooks,) that I’ll publish once I have them working. I’d love to hear your approaches to triggering scripts like this!


