I was looking for it too, so if you wanted to use a third party plugin that isn't supported in the current list of GitHub Pages, you'll have to build and push manually the static files to the remote branch gh-pages, letting it only with the static files. as they pointed in their page GitHub Docs
So to send the static files and let only the build content in the remote branch gh-pages do this:
- First make sure you already have the branch gh-pages in your GitHub repository;
- In your project create a folder with the name '_site_ghpages';
- Add it to your .gitigore file;
- In the Git bash/shell change the directory to the folder '_site_ghpages':
cd _site_ghpages
- Clone only the remote branch gh-pages of GitHub to the folder '_site_ghpages':
git clone --branch gh-pages `git config remote.origin.url` _site_ghpages
- Delete all the content if any;
- Copy all the content of the build folder '_site' and paste in '_site_ghpages' folder;
- in the folder _site_ghpages add and commit all the files:
git add .
git commit -m "My commit message"
git push
- Go back to the previouly directory.
cd ..
In this way each time you update your content, you should go to the folder '_site_ghpages'; clean it up; copy the content from the folder '_site'; paste in _site_ghpages, open the git bash in the folder '_site_ghpages'; add all the files, commit it, and finally push to the remote branch gh-pages.
Honestly all this process is a bit boring. So to workaround it I maked a script in bash that does all the above but automatically.
I put it in a repository so if you prefere you could check and download it here.
First make sure of:
- Ignore the PUSH_FOLDER ('_site_ghpages') in the .gitignore file;
- Already have a branch called "gh-pages" created in your repository (After run the script this branch will have only the static files of the build folder).
To execute the script first you should allow it to run as a executable in your machine, to do so, with Bash/Git Bash run:
chmod +x push_ghpages.sh
After that just run the file calling:
. push_ghpages.sh
When called without argument the script push with a 'Automatic commit' message.
So if you want to set your commit message just pass it as a argument, like this:
. push_ghpages.sh "Your commit message goes here."
If you have any problem while execute, just delete the PUSH_FOLDER, empty the remote gh-pages and let the script rebuild e push the content.
Also enter the PUSH_FOLDER cd my_push_folder_directory
and run a git branch
to check if it have ONLY the branch gh-pages, if it have a master branch or any other, delete it.
#! /bin/bash
# Author: [email protected]
# This is a script used to automatically deploy a Jekyll website/blog with third party plugins to GitHub Pages.
BUILD_FOLDER="_site";
PUSH_FOLDER="_site_ghpages";
COMMIT_MESSAGE=$1
#Remove all the content from the "PUSH_FOLDER".
function removeAllContentFromPushFolder(){
rm -r $PUSH_FOLDER/*;
}
#Create the folder "PUSH_FOLDER".
function createFolderToPush(){
mkdir $PUSH_FOLDER
}
#Copy all the content from the folder _site to PUSH_FOLDER.
function copySiteToFolder(){
cp -r $BUILD_FOLDER/. $PUSH_FOLDER
}
#Clone only the branch "gh-pages" to the folder "PUSH_FOLDER".
function cloneGhpages(){
git clone --branch gh-pages `git config remote.origin.url` $PUSH_FOLDER
}
function prepareThePushFolder(){
if [[ -d ./$PUSH_FOLDER ]]
then
#Remove all the content from the folder "PUSH_FOLDER".
removeAllContentFromPushFolder
else
#Create the folder "PUSH_FOLDER" if it doesn't exist.
createFolderToPush
#Call the function that clone the branch "gh-pages" to the folder "PUSH_FOLDER".
cloneGhpages
#Remove any prevous content from the folder "PUSH_FOLDER".
removeAllContentFromPushFolder
fi
#Call the function that copy all the content from the folder _site to "PUSH_FOLDER".
copySiteToFolder
}
function changeDirectoryToGhpages(){
cd $PUSH_FOLDER
}
function setMessageCommit(){
if ! [ "$COMMIT_MESSAGE" ]
then
COMMIT_MESSAGE='Automatic Commit'
fi
}
function pushBranchGhpages(){
git add .
git commit -m "$COMMIT_MESSAGE"
git push
}
function changeDirectoryBack(){
cd ..
}
prepareThePushFolder
changeDirectoryToGhpages
setMessageCommit
pushBranchGhpages
changeDirectoryBack