My static site generator of choice remains the Jekyll, although there are many great alternatives. This very blog uses Jekyll as its static site generator.
In my time with Jekyll, I’ve learned a few tricks which have increased my writing efficiency. In this post, I’ll show you a Thor script I use to generate scheduled blog posts. This approach will work for other static site generators, but it utilizes Ruby as its already a dependency of Jekyll. Feel free to adapt it to your needs.
What Is Thor
Thor is a Ruby gem that allows developers to build command-line tools effectively.
Thor is a simple and efficient tool for building self-documenting command-line utilities. It removes the pain of parsing command-line options… –Thor
To get started using Thor, you will need to install the gem. There are two methods to doing so. The first is to install the gem globally.
We can also add Thor to our GEMFILE.
Once we have Thor installed, we can invoke it via the command-line.
We’ll see how the command works a little later, but the breakdown is straightforward.
-
thoris the ruby gem -
jekyllis the name of ourClassthat has commands -
newis the command within our class - the rest of the text is the title of our blog post
Thor Power For Jekyll
I have two Thor commands I can use when publishing new posts: new and next. The new command creates a new file template based on today’s date. The next command picks the next Tuesday or Thursday based on the published date of the latest post. Let’s see how they work in the command line.

And now the next command.

Notice how the next command, keeps incrementing the post dates. This is awesome for blogging on a set schedule.
Thor Commands
To use these commands, create a file at the root of your Jekyll directory named jekyll.thor. You may change the template by modifying the contents of the create_file method. Here is my file in its entirety.
Note, you will need to have the gems stringex and thor added to your GEMFile.
Conclusion
By creating a robust blogging infrastructure, you can spend more time writing and less time fiddling with your platform. Thor is a great mechanism to build an efficient local environment. I hope you’ve learned something new, and let me know if you think of other Thor commands that enable your blogging experience. For Asgard!

Photo by 