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_dirfor Webby - The Webby site (source files) are in a subdirectory name
_webby - The
webbycommand line tool should be run from within the_webbydirectory, not the root of the repo - The Webby
clobbertarget is overridden to ignore the_webbydirectory Sitefile
1 SITE.output_dir = '..' 2 3 task :default => :clean_build
lib/override.rbRake 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.rakeredefinesclobberto ignore the_webbydirectory and the new (default)clean_buildtask 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:
- Change directory to
_webby - Generate a new blog post
- Run
webby autobuild - Edit until completed
- Commit all changes locally (
git add .from the root) - 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.