Middleman Deploy to Github User Pages
Middleman has come a long ways and so have my habits. My blog is now running a stock version of the latest Middleman App.
I wanted to share this very simple rake task for deploying to Github User Pages.
Add Rake to Gemfile
and remember to
bundle install --path=vendor
Deploy Rake Task
desc "Deploy" task :deploy do puts 'do build' # build folder system "rm -rf build" system "mkdir build" # git Dir.chdir("build") do system "git init ." system "git remote add origin email@example.com:YOUR_ACCOUNT/YOUR_REPO.git" system "git checkout --orphan gh-pages" end # do build system "bundle exec middleman build" # push build Dir.chdir("build") do system "git add -A" system "git commit -m build" system "git push -uf origin gh-pages" end end
NOTE: this is for a project page; if this is a user page you need to put your code in a source branch and have this publish into master.
Try it out
bundle exec rake deploy
Note the greatness * it builds static assets into gh-pages branch * does a force push so your repo doesn't continually get bigger