Tips/UsingAnUploadTask

Using an upload task

To upload nanoc-generated sites, I use a Rake task that invokes rsync. Depending on the OS you are using, rsync may or may not be installed yet (it is on Mac OS X). The Rake task looks like this:

task :upload do
  # This tasks uploads the content of the 'output' directory to the web
  # server. This specific rake task is specific to the Stoneship web site, but
  # it should be easy to adjust it to meet your own needs.
  #
  # This tasks requires rsync.
  #   
  # To configure, set 'src' to the path of the output directory on your local
  # computer (include a trailing slash). Set 'dst' to the path to your web
  # root (without trailing slash). Take a look at the example to see how it's
  # done (it's just a really simple rsync wrapper though).

  # Settings
  src = '/Users/ddfreyne/Documents/Development/nanoc/sites-stoneship/output/' # trailing slash
  dst = 'ddfreyne@ectype:/home/ddfreyne/sites/stoneship/public'               # no trailing slash

  # Don't touch this!
  puts 'Publishing site...'
  sh('rsync', '-gpPrvz', '--exclude=".hg"', src, dst)
  puts 'Site published.'
end

You'll have to update the src and dst variables, as explained din the comments.

This task (invoked like this: rake upload) uploads the contents of src to dst.

Depending on how you use your nanoc site, you may wish to skip any Subversion-related directories using the --exclude='.svn' option. There are quite a few more useful rsync options; I recommend checking out the rsync manpage.