I mentioned in my latest weeknotes that I’ve started using Rake to automate writing tasks for this site. The first ones were for creating a new post and deploying it. I can now run a command that creates the files and opens my editor for writing.
I’ve wanted to add a way to schedule posts. Lots of times, I keep an idea in my head, sit down to write it out, then immediately publish. I’d like to get into a habit of writing smaller things more often and scheduling them to publish automatically.
But I didn’t want to set dates. If I wanted to bump a writing in the schedule, I’d have to edit all the dates.
Today I wrote a Rake task that does the scheduling for me. Now I run:
This does a few things.
- Creates a new file using the post archetype
- Pushes the filename to a
- Opens the new file with iA Writer
The archetype file sets
true. The date is set to today, but I don’t care about that at this point. I’ll change that when I publish it.
I have another task called
schedule:publish. This will do:
- Grab the first item in
- Set the date to now
- Update the content file and the
At that point I can run
rake deploy, which commits everything in the content folder and the schedule file and pushes it to GitHub.
You can see the code on GitHub.
Once I get some content scheduled, I’ll write a GitHub Action to automatically publish on a recurring basis. I also want to tinker with a draft process that doesn’t automatically schedule a post.