Introduction
The scope of this article is to show you how to create a simple script to speed-up some operations for the deploy of the web-site.
Of course, we need to move all the files (in the public folder) into the remote folder through an FTP service.
Install an FTP
Mac/Linux
I have tried many command line clients, but the only one that allowed me to move all the contents of the public folder (including folders), to the remote one, was ncftp [link]
To install it, open the terminal and digit
brew install ncftp
Or just visit the download page
Windows
As I said before, you can visit the download page or you can use a powershell command to put the files in the FTP. Another suggestion is to use WinSCP
Create the script
So, now we are ready to write the batch.
Mac/Linux
Open a text editor and write this
#!/bin/bash
cd "THE_WEBSITE_LOCALPATH"
rm -r public
hugo -D
ncftpput -Rvm -u "USERNAME" -p "PASSWORD" IPADDRESS /REMOTE_PATH public/*
Now, save the file with the extension .sh
Windows
You can follow this link to the WinSCP documentation to create a simple script to upload the files.
That’s all!
You can run the script and test it!
