I’m not going to post the whole article I wrote on my website about it here, but if you are interested, I documented the way that I automatically deploy Hugo to Gandi simple hosting.
Situation:
- Hugo code on github
- HTML files on github in separate repository
- Site on gandi simple hosting (PHP/MySQL instance) which updates within 1 minute of git push to github html repository
In short, how did I do it:
Bash script:
- generates hugo site after first cleansing the deploy dir. (Not the standard public directory)
- asks for commit message
- pushes hugo source code to github
- pushes html files to github
Webhook on github with php file on simple hosting that does a git pull.
Here is the bash script:
#!/bin/bash
cd FULL_PATH_TO_HUGO_DIRECTORY && \
echo -e "\033[1mDeleting files\033[0m" && \
rm -rf && \
echo -e "\033[1mGenerating hugo site\033[0m" && \
hugo -d "PATH_TO_DEPLOY_DIRECTORY" && \
echo -e "\033[1mGit commit + push\033[0m" && \
read -p "Commit description: " desc
git add . && \
git add -u && \
git commit -m "$desc" && \
git push &&
cd PATH_TO_DEPLOY_DIRECTORY && \
git add . && \
git add -u && \
git commit -m "$desc" && \
git push
Off course change the paths to the different directories.
for the complete explanation check it out on my website