Tullio Facchinetti

Using rsync to update a remote Hugo website

by Tullio Facchinetti

Categories: article lang_en article_en

After having moved to Hugo for my personal website, I found that the usual way of using rsync to update the copy of the website on the remote server does not work efficiently. In particular, everytime I rebuild the local copy of the site with Hugo, and I run the command to synchronize the remote copy, all the local files are uploaded to the server.

This happens because Hugo regenerates all the files at every local build. For this reason, when rsync checks the changes in the modification times between local and remote files, the local ones are all always newer, and thus all of them are uploaded remotely.

To limit this problem, I use this workaround. I have a local directory called upload/, which is located in the same Hugo base directory. The upload/ directory is kept synchronized with the Hugo’s public/ directory. The synchronization is not done by modification date, but by file checksum, which is one of the methods provided by rsync. In this way, the files in the upload/ directory are updated only when there is an actual change in the content within the public/ directory.

Afterwards, I can use the usual remote synchronization method between the local upload/ directory and the remote server using the modification times.

The following sync.sh bash script does all the work:



rsync -r --delete --checksum $BASEPATH/public/ $BASEPATH/upload/
rsync -avz --delete $BASEPATH/upload/ username@your-server:remote-directory/

It would be possible to directly perform the synchronization between the local public/ directory and the remote server using the checksum method. However, this incurs in a large overhead due to the checksum operations done in the remote machine.


  • Students and theses
  • Publications
  • Thesis topics
  • Curated awesome list of CLI apps
  • Last updates (English)

  • Speed up the compilation of LaTex Beamer presentations ()
  • Students and theses ()
  • Students and theses - English ()
  • Learn enough C to survive ()
  • Workflow for writing theses collaboratively ()
  • Guidelines for theses and presentations ()
  • Projects ()
  • Last updates (Italian)

  • Risultati FdI 8 e 11 aprile 2024 ()
  • Risultati FdI 20 Febbraio 2024 ()
  • Risultati FdI 02 Febbraio 2024 ()
  • Risultati FdI 20-27 Novembre 2023 ()
  • Risultati FdI 28 Settembre 2023 ()
  • Risultati FdI 01 Settembre 2023 ()
  • Risultati FdI 27 Luglio 2023 ()
  • List of categories

    Article Article_en Article_it C Courses Fdi Lang_en Lang_it Latex Programming Project Research Results Robotics Software Teaching Thesis Tips