Created
June 13, 2019 11:55
-
-
Save synesthesia/839078d6c4519fb3d48ad4d59584f3e2 to your computer and use it in GitHub Desktop.
Publishing a Hugo site to both Netlify and 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
public/ |
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
#!/bin/bash | |
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" | |
# if public dir exists, delete it | |
if [ -d public ]; then | |
rm -rf ./public | |
fi | |
# clone the github pages repo | |
git clone CLONE_URL_OF_GITHUB_PAGES_REPO public | |
# build the site | |
hugo -t academic --gc --minify -b BASE_URL_OF_GITHUB_PAGES_SITE | |
# Go to the build folder | |
cd public | |
git add . | |
# Commit changes. | |
msg="rebuilding site `date`" | |
if [ $# -eq 1 ] | |
then msg="$1" | |
fi | |
git commit -m "$msg" | |
# Push source and build repos. | |
git push origin master | |
# Come Back up to the Project Root | |
cd .. | |
rm -rf ./public | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment