I've started using the same technique as Octopress uses, it works great for Middleman.
Basically I use two git repositories, one inside the root folder and one inside the build folder. The root repository pushes to the develop
branch on the GitHub remote and excludes the build
directory. The repository inside the build
directory pushes to the master
(or gh-pages
) branch of the same GitHub remote.
To automate the pushing of the new static pages, I use the following Rakefile:
desc "deploy build directory to github pages"
task :deploy do
puts "## Deploying branch to Github Pages "
cp_r ".nojekyll", "build/.nojekyll"
cd "build" do
system "git add ."
system "git add -u"
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated website"
system "git push origin master"
puts "\n## Github Pages deploy complete"
end
end