Deploying Hugo With Rsync

This is the script I use to deploy my Hugo website to Vultr.

    #!/bin/sh
    USER=username
    HOST=hostip
    DIR=nginx-web-root-absolute-path

    hugo && rsync -avz --delete public/ ${USER}@${HOST}:${DIR}

    exit 0

It requires that you have ssh access to the server you are trying to deploy to, and it also requires that the said server has rsync installed as well.

The key command here is rsync -avz source destination .

The -a option is a combination flag. It syncs resursively and preserves the symbolic links, and permissions, -v just means verbose output, and -z option on the other and enables compression.