Hugo+rsync+lftp Website Publishing

Normally, when Hugo generates a static website, timestamps of many files change even if their content remains identical.
This makes incremental updates inefficient when using FTP tools that rely on file timestamps for differential synchronization.
We can solve this using rsync
.
Create an ftp-public
directory as a local mirror of Hugo’s output public
directory. This divides website publishing into two steps:
- Use
rsync
to synchronize changes to theftp-public
directory. This step compares file content differences, only updating changed files while preserving timestamps of unchanged files. - Use
lftp
to synchronize theftp-public
directory to the website’s FTP server.
Here are the specific commands:
rsync -rv --delete --checksum --progress public/ ftp-public/
Explanation of rsync
options:
-r
Recursively sync subdirectories-v
Verbose output--delete
Remove files/directories fromftp-public/
that don’t exist inpublic/
--checksum
Use checksums to determine file differences and update needs--progress
Show synchronization progress
lftp -e "mirror -R --delete --only-newer ftp-public/ /" ftp://ftpuser@ftpserver