Make things easier for yourself by providing a script to upload the webpage, prepared statically by Hugo, to your own FTP server
.
Prerequisites
- Hugo
brew install hugo
- lftp
brew install lftp
- shell
zhs for macos in my case
AC
- make hugo build all the latest static pages by invoking
hugo
- upload the necessary files & folders to the FTP server using lftp
- limit the upload option to
add
new files and overwrite
existing ones in order
not to remove other files on the server
The script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
# Provide your data
USER=ftpuser # insert your ftp user
PASS=ftppass # insert your frp password
HOST="krzysp.net" # insert your hostname
FOLDER="~/my-hugo-folder/" # the local folder with the hug website
LCD="$FOLDER/public/" # source, local path where hugo builds static pages
RCD="/domains/public_html/" # target, on-site, path to uplaod to
pushd $FOLDER
hugo
popd
lftp -f "
open $HOST
user $USER $PASS
lcd $LCD
mirror --overwrite --reverse --exclude .git --only-newer --ignore-time --verbose $LCD $RCD
bye
"
|