The long way through Software Craftsmanship

Faster site generation for Octopress 2

Jul 13, 2015 - 2 minute read - Comments - metaoctopress-2octopress-3octopress

2016-04 update: I’ve discovered that the original Rakefile does a similar job. See here

After a while, the generation of the static site using Octopress 2 was starting to be slow (around 2 minutes for 85 posts) for the kind of fast feedback cycle I was expecting.

Inspired by their new features in Octopress 3, one of them being faster site generation, I decided to retrofit my installation with the same feature.

Octopress 3 now has a different structure of posts and drafts. You can specify you only want to publish to your local preview your current draft instead of all of them, therefore being it faster. When you finish editing, all the posts are recovered and publishing to production uploads all of them

For Octopress 2, you can do something similar in a manual way. Create a copy of your working environment:

cp -R blog_source blog_post_factory

Git ignore all existing markdown files in the folder source/_posts

cd blog_post_factory/source/_posts
git update-index --assume-unchanged $(ls *markdown)

Delete all existing markdown files

rm *markdown

Check that git doesn’t realize about the difference:

git status

# On branch source
nothing to commit (working directory clean)

Create a new post:

rake new_post["Faster site generation for Octopress 2"]
# On branch source
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	2015-07-13-faster-site-generation-for-octopress-2.markdown
nothing added to commit but untracked files present (use "git add" to track)

Edit as much as needed, reviewing changes in local. Push to the remote repository.

In the original (blog_source) folder, pull, then generate:

rake generate && rake deploy

[Optional: change the remote URL for the cloned repository, so the git push is faster.]

After each new post, you have to ignore old files again. I’ve created a new task in the Rakefile for this purpose:

desc "Cleans all *.markdown files for a faster site generation"
task :ignore do
  cd "#{source_dir}/#{posts_dir}"
  system "git update-index --assume-unchanged $(ls *.markdown)"
  system "rm $(ls *.markdown)"
end

Conclusion

I’ve reduced the amount of time to generate files from 2 minutes for 85 files to ~0.62 seconds for 1 file.

Regenerating: 1 file(s) changed at 2015-07-13 08:03:29 ...done in 0.617269045 seconds.

Disclaimer about AI/GenAI

As of 2026-05-06, the text in these articles and blog entries has been written without AI/GenAI, except I sometimes use a spellchecker to fix errors. Think Word's spellchecker, not ChatGPT.

Notes, as of today (2026-05-06):

  • No code snippet has been automatically generated, nor vibe-coded, nor generated and reviewed.
  • I don’t have any article with AI contribution.

For future entries:

  • I may have used GenAI for the code in the repo. The code I exemplify/copy in the article will always be reviewed and tested, not vibe-coded. I will specify it in each snippet or at the top/bottom of the article.
  • I normally don't use it for the text contents, although if I have used it for the article text, it would be indicated as such.

Any entry before 2026-05-06 does not contain any AI/GenAI.

For more information, read the AI/GenAI Policy

What defines a dependency Practical Object-Oriented Design in Ruby: Chapter 4