[SOLVED] Hugo site deployment with rsync


My site is hosted from a “public_html” directory that also contains files unrelated to my Hugo site. (I can’t remember how this came to be. Perhaps I should change it in some way.)

When I previously had an Octopress site, I used a “rsync-filter” file in which all these unrelated items were listed, each preceded by “P” Rsync would leave these alone.

Octopress has a “rake deploy” command. A Rakefile contained the following:

rsync_delete = true
rsync_args = "–filter=‘merge rsync-filter’"
deploy_default = “rsync”

How do I replicate this for my Hugo setup ?




I’ll answer my own question.

I use the following:

rsync -avz --delete --exclude-from '/Users/howardm/hugo/chestradiologists.orgSite/Exclude.txt' public/ ${USER}@${HOST}:${DIR}

(I used the ${DIR} formulation because I had to prescribe the entire path to my web directory on the server.)

In the Exclude.txt file, I list all the excluded items, one per line. For an excluded directory, I added a trailing slash after the directory name.

For those relatively new to rsync like me, I first tested the command with the -n ( a dry run) and an extra -v (verbose) option to carefully inspect what rsync was going to do.



@howardm Since this is solved and now reads more like advice, you might want to change this category to tips and tricks…