hugoRoot='/Users/xxxxxx/hugo/blog/' # your local hugo website root
publicFolder='/Users/xxxxxx/hugo/blog/public' # your hugo website PUBLIC root
zipName='Archive.zip' # the zip name
zipLoc=$publicFolder/$zipName # No need to change
hostname='xxx.xxx.xxx.xxx' # server address
upTo='/www/wwwroot/webxxx' # the root of the website on server
The ssh login is root by default, you may need to change it by yourself.
When you run the script the hugo will generate the public files. There's no need to hugo again.
I take the simple way to update the website which means the script only upload files without checking the files may needed be removed.
Generally, the script do:
Generate Hugo public files
Compress the public files in one file
Upload the zip package
Decompress the zip and Delete it
and not do:
Check files iteration, it just covers the same file.
Do nothing with files exists.
Security & Convenience
For security I set ssh password shall be entered every execution.
Of course, you can set a variable named sshpw at the front of script, and comment out line 26 ~ 29 .
My own specifics
I found somehow it generated __MACOSX in the zip file. Hence I remove it after uploadding by line 42 rmdir __MACOSX
Perhaps it's not right command because failure occurs when the folder is not empty, using rm -rf __MACOSX is better.
But it's not a really issuse so I ignored even as you can just remove this command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters