3.2. Build and Upload a Hugo Site
Build a Static Version of the Hugo Project
To build a static version of a Hugo site project, just call
hugo
in the Hugo project directory.
The static version of the site will then be available in the subfolder public
of the project.
Upload and Sync the Static Site via FTP
Since many hosting products allow only FTP access to upload the contents, here the tool lftp
is used.
If lftp
is not already available, it can be installed from package sources:
Install lftp:
sudo apt install lftp
sudo dnf install lftp
Using the following bash script will upload the entire contents of the publish directory to the webhosting FTP server:
#!/bin/sh
set -x # show executed commands
lftp -c "set ssl:verify-certificate no; \
open -u ftp_username,ftp_password ftp_server; \
mirror -R -e local_path ftp_path"
set +x
ftp_username
is the user login name for the FTP server.ftp_password
is the user password for the FTP server.ftp_server
is the address of the FTP server.ftp_path
is the folder on the FTP server to store the Hugo site to.local path
is the local path of the publish folder which contents need to be uploaded. It is important to add/*
at the end.