Now that I have Octopress installed along with the s3_website plugin so that I can easily publish to Amazon S3 and CloudFront, I wanted to make it a little easier to do common tasks like creating a new blog post or page, generate the static pages, and publish the site to the web.
Prompting for Page and Post Names
To ensure all appropriate characters are converted for the URL names, I wanted to have the new post and new page tools prompt for the title rather than passing it as an argument, which can sometimes cause problems in parsing special characters or spaces along with making aliasing the commands much more complicated. Luckily the new_post function already has this ability, but the new_page tool does not, so it needs to be added to the Rakefile. Here’s the diff to add that to the Octopress Rakefile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
In addition, I wanted to create some terminal shortcuts for creating a new post, page, for generating the static pages, and finally for publishing the changes to the web. To do that, since I use bash as my shell, I simply added the following to my ~/.profile:
1 2 3 4
Now every step can be accomplished with a single word so I no longer have to remember the syntax and commands, even though they aren’t terribly complex anyway. Remember, you must source your new .bashrc file to activate it after making any changes. This is simply done by executing