Are you trying to figure out how to make Jekyll work for you, on Reclaim shared hosting, with Git, but without having Github stuck in the middle? Me too. Until recently I was doing it on another service starting with a D but their VPS service has gotten too expensive and their panel has ads everywhere. So I decided to move it. All this stuff comes from Geeky Martian, Dave Ceddia, and Stackoverflow.
Git magic. Your development process will look like this:
1) Make your Jekyll site locally. I like to preview it locally too. Jekyll docs can tell you how to do all this.
2) Push it to your server.
3) The entirety of your jekyll folder will check into a folder *outside of your web directory* (where nobody can get to it). And the web files, generated into _site as Jekyll does, will be copied into your public facing web directory automagically, using a GIT "post-receive hook". I like this setup because it means I have a backed up copy of my entire Jekyll development folder, rather than just pushing the generated site, which you could do much more trivially with Git but who wants that.
- you have shell access to your Reclaim account.
- you know how to use Jekyll. This is just about the Git deployment. Jekyll has good documentation on the actual site building.
- you know roughly how a repo works, and how to add and commit files locally.
- Note that I'm working on a Mac - the only thing this affects is step 1.
- Also, for the purposes of this test I'm using a subdomain,
jekyll.polyrhetor.io, which is in my home folder (not inside public_html). Anytime it says below
<webdomain> you'll put in your own domain name (or subdomain if that's where you're serving from, like me).
- Warning. I'm a little leery of trying out the root domain inside
public_html since Reclaim seems to put other things in there, and they might get wiped. So I strongly recommend doing this on a subdomain until you have it figured out.
Ok, let's go.
On a Mac: download ssh-copy-id so you don't have to deal with weird Mac pathnames. If you're on linux you can skip over this. I have no info on PCs.
brew install ssh-copy-id
Now generate a key for your local machine:
ssh-keygen -t rsa
Hit enter a bunch of times and it'll generate a key and stick it... somewhere.
Now copy it to your Reclaim account:
Reclaim will ask you for your usual login password, and then install the key. Now try logging in again. This time you should use be able to ssh to your server and it will not ask you for your password any more.
nb All the stuff in this section happens on your server, not your laptop.
1. In this step, you're going to be making a "bare repo." This is a repo that doesn't take any of your actual content: it just stores all the tracking information and tells everything where to go. You can call it anything but end it with .git so you remember what it is. For reminders sake I've used my subdomain name all the way through so I can remember what's related to what.
git init --bare
It should say "Initialized empty Git repository in /home/<username>/<webdomain>.git/". Doing an
ls should give you:
config description HEAD hooks info objects refs
2. Now make the hook, which is where the magic happens. This is a series of instructions written into a file called "post-receive", which sits inside your bare repository in the "hooks" folder. You could do anything with this thing. Anything. I'm using nano:
Copy and paste this stuff, changing your domain name to match on line 3:
#!/bin/bash # Replace this value with the actual domain name (or subdomain) that you want to serve from DOMAIN=<webdomain> echo echo "~~ Updating $DOMAIN ~~" echo # Clearing git env unset GIT_DIR unset GIT_WORK_TREE # auxiliary domain storing the entire jekyll tree (all repo content) cd ~/$DOMAIN-jekyll git pull # get to the static build directory cd _site # delete domain contents rm -rf ~/$DOMAIN/* # copy that to our real domain path cp -R * ~/$DOMAIN echo echo "~~ Done ~~" echo
3. Write out & save the file, then chmod permissions so it will run:
chmod +x <webdomain>.git/hooks/post-receive
4. Now you're going to clone your bare repo to a new folder, which is where all your jekyll files (not the live ones) will be stored. Name it something like <webdomain>-jekyll. Eg I called mine jekyll.polyrhetor.io-jekyll:
git clone <webdomain>.git <webdomain>-jekyll
At this point, you're going to have THREE relevant folders in your home directory. Using my example:
jekyll.polyrhetor.io <-- where my live final site lives
jekyll.polyrhetor.io.git <-- the bare git repo
jekyll.polyrhetor.io-jekyll <-- where my jekyll development files live
1. Make a new folder where you want your Jekyll development files to live, and initialize it as a repository:
2. Make a couple of test files. I made one called README.md. To test the Jekyll magic stuff, I also made a subfolder _site (like Jekyll would) and put another sample file inside it (the instructions you're reading right now).
3. Add and commit all the files as usual:
git add -A
git commit -am "first commit"
4. Ok now next step is to hook up the local & remote:
git remote add live ssh://<polyrhet>@<servername>/~/<webdomain>.git
5. Finally, you can push the sucker.
git push live master
5a. Problems? Ugh. I got stuck on this for SO LONG because of branches. If you start getting horrible errors like this,
error: src refspec master does not match any
error: failed to push some refs to 'ssh://<webdomain>/~/<webdomain>.git'
... then do this:
Does it say that your branch is "main"? If so, you'll need to change it to master:
git branch -m main master
Now when you do
git status it should read
On branch master
Phew. Now you can try pushing again.
Once it's all sorted, and you've done a push successfully, check the -jekyll folder on the server and you'll see the whole shebang; check the actual web domain and you'll see the site as generated.
Once all that's set up you can make a Jekyll site as usual, build & test it locally, and push it from your tracked folder whenever you want.