Last active
April 3, 2020 16:57
-
-
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
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
#!/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