Skip to content

Instantly share code, notes, and snippets.

@megrxu
Created February 26, 2018 10:56
Show Gist options
  • Save megrxu/fea586de50f6ba2dcfb9b068a23fd650 to your computer and use it in GitHub Desktop.
Save megrxu/fea586de50f6ba2dcfb9b068a23fd650 to your computer and use it in GitHub Desktop.
deploy the gh-pages from a hugo site folder
#!/bin/bash
echo -e "\033[0;32mDeploying gh-pages to GitHub...\033[0m"
# Clean
rm -rf public
# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`
# Change to gh-pages
cd themes/GoMDL
git checkout gh-pages
# Clean and update
rm -rf ./*
cp -r ../../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 gh-pages
# Come Back up to the Project Root
git checkout master
cd ../..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment