Johnathan.org

Johnathan.org • A technology blog produced by Johnathan Lyman covering a variety of tutorials, thoughts, and commentary on all of the technology around us.

How I Made Jekyll Post Generation Just a Touch Easier

Now that I’m running my blog using Jekyll, one thing I’ve already found to be rather frustrating is the post generation process. I have a blank .md template I open, save in a new location, then edit, but that seems cumbersome, to me. What I decided to do instead is write a quick Ruby script that generated a post .md file for me based on the information I provide.

Thought Process

I wanted to keep it simple, and just do only what I really needed. I don’t need any fancy logic or checking. I know _posts will be there because I put post_generator.rb inside my Jekyll directory.

Working Example

Here’s my code as it stands inside right now:

.gist table { margin-bottom: 0; }

It’s functional. It’s not clean and could be refactored a but, but it works.

Improvements

A few things that came to mind after I finished: – Use the system date if none is provided – Re-format the title with title-casing. Without ActiveSupport in Rails, I’ll have to either require it as a gem or write something by hand. I’m thinking the former. – Allow the user to write the post right there in the command line and not have to open a text editor. – Allow the user to choose which text editor to use at the prompt (perhaps with detection?)

It’s a good first draft and it serves the purpose I had in mind. Here’s the GitHub repo.

Enjoying these posts? Subscribe for more
Subscribe now

Subscribe to be notified of new content and support Johnathan.org! You'll be a part of the community and no longer see ads.

You've successfully subscribed to Johnathan.org
Great! Next, complete checkout for full access to Johnathan.org
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.