We want to create a Jekyll site hosted on a cPanel server and using a GIT repository for versioning.
This could be done with GitHub and a WebHook, but in this case, lets keep the GIT repository on the server.
This assumes we have a cPanel hosted account with SSH access and Jekyll installed on the server. The basic process will be
- Create a GIT repository on the server –
- Create a location for the uncompiled source files –
- Create a GIT hook to extract the changed source files and the build them into the
- Clone the GIT Repository on the local machine and edit it
Log into the Server
Set up the Server
git init --bare jekyll.git git clone jekyll.git source_code
Set up GIT Hook on
touch jekyll.git/hooks/post-receive chmod +x jekyll.git/hooks/post-receive vim jekyll.git/hooks/post-receive
Add hook code
#!/bin/sh cd $HOME/source_code/ || exit unset GIT_DIR git pull origin master && jekyll build --destination $HOME/public_html
You can test this by running
cd ~/source_code jekyll build --destination ../public_html
To make sure that Jekyll can be found in the GIT Hook, we can also add an
env > .ssh/environment
Now exit the server and find a location on the local machine to clone the repository.
git clone ssh://firstname.lastname@example.org:22/home/user/jekyll.git
This command can be used to test everything works
echo `date` >> index.php && git commit -a -m "index" && git push