Skip to content

Instantly share code, notes, and snippets.

@nmrony nmrony/
Last active May 18, 2017

What would you like to do?
Auto git push script to post Ghost blog to Github Pages


I am asumming that you have following this already taken care in your dev machine

  1. Fully configured up and running Ghost blog
  2. Successfully installed Buster Script
  3. Already have Git Page for your account


Follow the steps below

  1. Go to your Ghost Blog root directory
cd /path/to/ghost/blog/root
  1. Clone your <your-username> repository in static directory under Ghost root directory. You can easily do it with the following command
git clone <your-repo-url> static
  1. Go to your ghost blog root directory if you are in static directory.
  2. Grab the ghost2git script running the following command and save it in your Ghost blog root directory
curl -fsOSL
  1. Open ghost2git in your favourite editor. Then find and replace the <your-github-username> with your github username. Save it.
  2. Make it executable using the following command
chmod +x ghost2git
  1. Run the script on your terminal using the following command when you add a blog post in your Ghost blog and want to push it to Gitpage
# Read the to configure this script according to your need
echo 'Generating static page from ghost blog..' && \
buster generate --domain= > /dev/null 2>&1 && \
echo 'Fixing link...'
find ./static -name "*.html" -print0 | xargs -0 sed -i'' -e 's#http://localhost:2368#https://<github-username>' > /dev/null 2>&1 && \
cd ./static && \
echo "Pulling latest changes..." && \
git pull --all -q && \
echo "Adding changes to stage..."
git add --all && \
echo 'Enter git commit message: ' && read COMMIT_MESSAGE && \
git commit -am "$COMMIT_MESSAGE" && \
git push -qfu origin master > /dev/null 2>&1 && \
cd $CURR_DIR && echo 'Your blog is successfully deployed to github';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.