I’m trying to make life less messy by learning an entirely new system.
I have a Wiki with 1000 or so pages and it’s running MediaWiki. And it’s overkill. I don’t update it often enough to need all the bells and whistles. I need it to be fast, I need it to be simple. I need it to work for one editor (hi). Oh and I need it to be secure.
Create a Git Repository
There’s a reason for this. My plan is to commit my changes for Jekyll to a git repo and then have it auto-copy the proper files up to the folder on my webserver. My git repository is private and on the same server owned by the same account, so I can do this. Once I had my bare git repo, I ran this in my local repository folder on my laptop:
git clone ipstenu@example.com:/home/ipstenu/repositories/jekyll.git site-jekyll
And I got a warning: warning: You appear to have cloned an empty repository.
Which I knew. But that’s fine. I wanted it empty.
Install Jekyll On Your Computer
Full stop. This is where I got confused before.
$ brew install ruby
$ gem install jekyll
That’s it. That’s how to get it started.
Create Your Site
I was still in that other folder, so I ran an install:
jekyll new . --force
The reason for the force was that I did have some git files in there and a readme. Then I spent a few hours trying to figure out how to write posts and pages in Jekyll. Posts are ‘easy’ in that you create a file named yyyy-mm-dd-PostName.md
and it will generate a post with that name. You can read up on Writing Posts for more.
But. I’m converting a Wiki and pretty much the whole thing is going to be ‘pages’. To be honest, Jekyll’s idea of pages are ugly. The Writing Pages directions want me to put it all in the same folder and I didn’t like that. I thought I’d rather write a mess of posts in the _posts
folder and then let Jekyll generate on the fly.
To do that was relatively easy. I set up permalinks:
# Outputting
permalink: "/:title"
After I did that, I realized I would still have to name things that ugly way, so I added this to my _config.yaml
file:
# Pages
include: ['_pages']
Then I made a folder called _pages
and put my files in there, named CSI_Crime_Scene_Investigation_(season_1).html
and so on, with headers like this:
---
layout: default
title: "CSI: Crime Scene Investigation (season 1)"
permalink: "/CSI_Crime_Scene_Investigation_(season_1)/"
categories: television
tags: csi
---
Yeah. It’s starting to make sense. I could change the permalink to ":/title/"
and get the same result, where it would match the filename. But for now, the basic idea is enough.
Themeing
It was harder than expected. I had to convert a lot of random PHP includes into Jekyll includes (pity I can’t just say ‘include this file, yes, I know it’s PHP…). Then I wanted to add some features like a table of contents, like I had from MediaWiki, which was a little tricky. But. Once I sorted out the way you do includes and how I could do them, it was all a bit easier.
Importing MediaWiki
This proved to be incredibly hard. Like table flipping, teeth gnashing, up at night, wondering why the universe was created this way hard. It was so hard, I exported the wiki to XML (easy), converted that to WordPress xml via Perl (hard because of dependancies), edit all instances of <wp:post_type>wiki</wp:post_type>
to be a post, import into a WordPress site (easy), and then …
Then I spent a long time going through the import, fixing the pages, formatting things, uploading images properly, etc. The wiki I was importing was old. It happens to be the oldest part of the website it’s on, and I was using a lot of templates. In a way that was great. But in another way it was really a terrible idea because it locked me in.
So a lot of things had to happen. First, I had to rebuild all my templates. The wonderful thing with this is that I was using a lot of templates to list things like episodes and I could convert those to yml (or csv) and then have Jekyll run a loop to display them. Once I realized that, it meant I had a lot more freedom with content.
I ended up not importing everything. A lot of what was on that Wiki was never looked at by anyone but me, and fifteen plus years of cruft leads to a lot of messy things. Between Jekyll collections and data, I was able to break things out into sanity again. But that’s a whole post on it’s own.
Pushing To My Server
I’m using Git, and it’s set to auto-push when I push. But this time I did it a little different. Normally I’d run jekyll on the server, but in this case I don’t have the option so I went with adding my _site
folder to the git repo (which meant editing .gitignore
) and then writing this:
#!/bin/bash -l
GIT_REPO=$HOME/repositories/jekyll.git
TMP_GIT_CLONE=$HOME/tmp/git/repositories
PUBLIC_WWW=$HOME/www/jekyll
git clone $GIT_REPO $TMP_GIT_CLONE
cp -r $TMP_GIT_CLONE/_site/* $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
This is not what I would consider a great idea. I’d rather run git on the box, but Ruby has been misbehaving there, and this actually lets me use the code on a shared box too.