Les Hill github twitter facebook linked in archives
Posted January 24, 2009

As of this post, this blog is now hosted by GitHub’s recently announced GitHub Pages, still Webby powered, now with extra git goodness.

GitHub Pages generates a static site from a GitHub hosted repo, using Jekyll to generate the files. Jekyll understands two special directories _posts and _layouts, copying any other files and directories in the root of the repo that do not begin with an _ directly to the static site.

Webby generates a static site from set of source files (content, layouts, etc), placing the results in the output_dir (defaults to output but can be changed.)

To make Webby and GitHub Pages co-exist, I restructured my repo and made the following changes to my existing Webby site:

  • The root of the repo is the output_dir for Webby
  • The Webby site (source files) are in a subdirectory name _webby
  • The webby command line tool should be run from within the _webby directory, not the root of the repo
  • The Webby clobber target is overridden to ignore the _webby directory
  • Sitefile
1 SITE.output_dir = '..'
2 
3 task :default => :clean_build
  • lib/override.rb Rake monkey patch to allow overriding tasks found here
 1 # From http://www.taknado.com/2007/7/30/overriding-rake-tasks
 2 Rake::TaskManager.class_eval do
 3   def remove_task(task_name)
 4     @tasks.delete(task_name.to_s)
 5   end
 6 end
 7 
 8 def remove_task(task_name)
 9   Rake.application.remove_task(task_name)
10 end
11 
12 def override_task(args, &block)
13   name, deps = Rake.application.resolve_args([args])  
14   remove_task Rake.application[name].name
15   task(args, &block)
16 end
  • tasks/github_pages.rake redefines clobber to ignore the _webby directory and the new (default) clean_build task allows for file deletions1
 1 # We only want to remove the generated files
 2 desc "Delete the website"
 3 override_task :clobber do |t|
 4   Dir.chdir(Webby.site.output_dir) do
 5     Dir['*'].entries.reject {|entry| entry == '_webby'}.each {|entry| rm_rf entry}
 6   end
 7 end
 8 
 9 desc "Clobber, then build the website"
10 task :clean_build => [:clobber, :build]

The new workflow for adding a post to the new site is:

  1. Change directory to _webby
  2. Generate a new blog post
  3. Run webby autobuild
  4. Edit until completed
  5. Commit all changes locally (git add . from the root)
  6. Push the changes

1 Webby does not know if you have deleted a source file, by forcing the entire site to be rebuilt, the deletion is reflected in the generated static files.

Thanks to Tom Preston-Werner for the CSS layout, Webby for the blog renderer, and GitHub Pages for the blog hosting.