As I blogged about earlier, Octopress is a great framework for writing blog posts and packs in all the features for writing a code-centric blogs. Of course, it goes without saying that the blog also looks awesome as if designed by a true designer. Some of the nicer things about writing posts is that there are rake tasks that do most of the grunt work:
- rake new_post[“Just type the title of the post here in plain English”]
This will create a new file under
- rake new_page[about]
This will create a new page under
- rake preview
This sets up a local webserver on
http://localhost:4000and starts monitoring the
sourcefolder for any changes. It automatically generates the corresponding HTML/CSS for the Markdown/SASS files respectively.
If you have just migrated from a Wordpress blog or have lots of posts under your
source/_posts, the rake task that generates the HTML output can take a very long time (several minutes). Obviously if you are just working on one post, there is no need to wait for the entire site to generate. What you are looking for is the rake isolate[partial_post_name] task.
rake isolate, you can “isolate” only that post you are working on and move all the others to the
source/_stash folder. The
partial_post_name parameter is just some words in the file name for the post. For example, if I want to isolate the post from the earlier example, I would use
This will move all the other posts to
source/_stash and only keep the
2011-09-29-just-type-the-title-of-the-post-here-in-plain-english.markdown post in
source/_posts. You can also do this while you are running
rake preview. It will just detect a massive change and only regenerate that one post from then on.
All set to publish
When you are ready to publish your site, just run rake integrate and it will pull all the posts from
source/_stash and put them under
source/_posts. Now you can run rake generate and then rake deploy to publish your updated blog.
If these seem like lot of commands to remember, don’t worry, they will become second nature once you do it few times. As a summary, below are all the tasks that we talked about in this post. The description of each task comes from the Rakefile used by Octopress. I just did a
rake list -T to get a dump of all the tasks.
- rake new_post[title]: Begin a new post in source/_posts
- rake new_page[filename]: Create a new page in source/(filename)/index.markdown
- rake generate: Generate jekyll site
- rake deploy: Default deploy task
- rake preview: Preview the site in a web browser
- rake isolate[filename]: Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much quicker
- rake integrate: Move all stashed posts back into the posts directory, ready for site generation