[Howto] auto deploy a hugo site on gandi simple hosting

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

Bunker, are you still around? I’d like to deploy my Hugo site to Gandi - and I could really use your detailed walkthrough as a starting point, even if it’s 10 years old now, but alas, the link no longer works…!

I am still around here. Even though this is a throwback…

Anyway, my website of that time is still available on my github GitHub - thebeardbe/achter.be: Achter.be source files for hugo · GitHub

the post in question is available at: achter.be/content/blog/20160226_hugo_git_deploy_automation.md at master · thebeardbe/achter.be · GitHub

However I don’t know if this still works as I have not used this for years.

Edit: I even found the original gandi cookbook article that I followed: auto deploy from GitHub to Simple Hosting — gnadi-cookbook 0.0.1 documentation

Thank you!!