Skip to content

Instantly share code, notes, and snippets.

@ningsuhen
Last active April 3, 2020 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ningsuhen/b544f17d31160890d774 to your computer and use it in GitHub Desktop.
Save ningsuhen/b544f17d31160890d774 to your computer and use it in GitHub Desktop.
deploy-hugo-site-to-github-pages A simple script for deploying static site generated by hugo into github pages
#!/usr/bin/env bash -xe
#allow passing a commit message
message=$1
if [ "$message" == "" ]; then
#use last git commit message for deploying into github pages
message=`git log -1 --pretty=%B`
fi
#generate static site into public & copy files into dist folder
hugo -d public
rsync -avh --delete public/* dist/
# push the files into github pages
cd dist
git add .
git commit -m "$message"
git push origin master #replace "master" with "gh-pages" if you are deploying into a project site
# go back to source directory
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment