WordPress is a great blogging platform but if you want something a bit lighter weight then Jekyll is a good bet. For me, I keep notes and todo lists and all that gubbins stored in plain text files formatted in Markdown. If I want to take a section of my notes and publish it online then I have to go into the admin section of WordPress and create a post and fill in boxes and reformat the text and it’s all a bit of a faff. Jekyll works the same way I do though. It stores articles in Markdown format in plain text files with no database complications, no worry about scripting complicated backups and I can easily write locally and deploy to my remote server with just a quick
git push deploy master. Here’s how.
I’m doing this on Ubuntu Linux so you may need to tweak things a little if you’re on Windows or Arch or macOS or whatever.
- Install Jekyll locally.
- Creata a local bare-bones Jekyll site.
sshonto the remote machine
- Create and add a key to
authorized_keyson the remote machine.
- Install Jekyll on the remote server.
- Create a folder to store the git repo on the server. E.g.
git init --bareto create a bare git repo on the remote machine to receive your content when you
git pushto deploy to it. Note that this is just a repo to receive the source files for the site. It’s not where the actual site will be built to or served from.
- Create a
- Create a folder to receive the built site from the git repo once Jekyll has built it. This is where the web server will serve your site from. E.g.
- Add a git remote to your local machine.
git remote add deploy email@example.com:/home/user/Documents/blog-repo.git
git push deploy masterto push your content up to the remote repo.
post-receivegit hook will spot the changes to your remote repo and build your site in your remote server’s web folder.
- Go to your web site’s address in your browser and bask in the glory.
jekyll-diagramsis handy if you need to generate diagrams on your pages.
sudo apt install ruby-full.
gem install bundler jekyllto install the
jekyllgems to the local repository.
Bare-bones Jekyll Site
jekyll new /home/user/Documents/blogto create a bare bones site.
cd /home/user/Documents/blogto get into your new site’s folder.
bundle exec jekyll serveto start the jekyll server and build your site.
- Now browse to
http://localhost:4000and you should see your site rendered on your local machine; something like this:
|Bare Site Screenshot|
Create a Post-Receive File
Change directory into the remote repo folder and create a file
#!/bin/bash -login REPO=$HOME/Documents/blog-repo.git SITE=/var/www/blog TEMP=$HOME/tmprepo git clone $REPO $TEMP export PATH=$PATH:$HOME/gems/bin BUNDLE_GEMFILE=$TEMP/Gemfile bundle install BUNDLE_GEMFILE=$TEMP/Gemfile bundle exec jekyll build -s $TEMP -d $SITE rm -rf $TEMP exit 0
chmod +x hooks/post-receive to make it executable. If you forget this your remote repo will get updated when you push to it, but the site won’t get generated.
- Edit the
Gemfileto include the following:
group :jekyll_plugins do gem 'jekyll-diagrams' end
- Then run
bundlefrom a command prompt to install it.
sudo apt install graphvizto install dependencies.
- Add some config to
diagrams: graphviz: engine: dot options: '-Tsvg' blockdiag: options: '-Tsvg --nodoctype'