Niklas' Blog

Latest Posts

Deployment via git

The local repository

You can host your site on Gitlab, Github or something else - just like I do.
But if you want to start from scratch you can make a folder and initialize git in it, after that you can copy over your Jekyll files.

The remote repository

Now we need a new repository on your web-server, but it doesn’t need to be inside your web directory - just somewhere inside the system. I assume you have configured your public-key to work as a login and you also need write-privileges to the web directory with this user.
First we need to initialize the repository:

Then we need define a post-receive hook that checks out the latest changes into the web-servers DocumentRoot (this directory must exist; Git will not create it for you):

nano hooks/post-receive

Put this inside the file:

#!/bin/shGIT_WORK_TREE=/var/www/www.example.org git checkout -f

After that we need to enable the hook which will be triggered every time we push our changes to this repository. It will apply every commit to the directory which you have defined inside the post-receive hook.

chmod +x hooks/post-receive

We are now done on the server and we only need to set up the update process on the local system.

The update process

First we need to edit our git config file in our local repository to add the remote server.

nano .git/config

Add this to the file:

[remote "production"]url= username@webserver:/home/nh/website.git

That’s it! Now you have set up your deployment! To deploy your jekyll changes is now as easy as this:

git push production

Make jekyll fly

This is the fastest site I've ever built.

before and after

Optimizing the web-server

Since I wanted to optimize my server I looked for a site which would allow me to test my servers performance and maybe also give me hints, than I found pingdom which is a really good tool to test your site!

Now I needed some optimization of my servers cache, for this I needed to use the mod_expires module of my apache installation.
I made a new file /etc/httpd/conf.d/expires.conf with the following content:

Wow such top. So stats. More better than regular top. Written in node.js
vtop

I’ve been using top since I started maintaining a server in 2010.
It’s a really powerful tool to glance at it and see if your system is alright, but since I discovered htop, top was made obsolete for me.

Although I really liked htop I always felt that it sometimes had a too clunky representation of the data, so that I couldn’t quickly enough see if my system was acting out of the common workload.

Than I discovered vtop!
But let’s start at the beginning of my journey.

Why not simple old top?

top vs htop

As you can guess from the pictures above htop does really exactly the same as top, but in a much nicer way so in my opinion there is no discussion about why you would choose top over htop!

vtop looks much cleaner than htop. One look and you exactly know whats going on on the system! You can list processes by CPU or Memory usage which is really awesome, you can navigate with your arrow keys or k and j which is also nice and the best of all you can simply highlight/select a process and kill it by typing dd!

You can install it also very easily through npm(you need to install node.js on your system)!

sudo npm install -g vtop

After that you can execute it by typing vtop

I really love it! Maybe there are some use-cases where I still need htop e.g. when I want to find a PID and don’t need it to kill the process, but vtop is now a part of my daily used tool!

Why i switched to Jekyll

I was thinking about switching from Wordpress to something else for quite a while, but I didn’t find anything I really liked.

First I thought about switching my blog to a self made Laravel site, but it’s kind of reinventing the wheel.
It’s a lot of work and is still open to bugs and exploits and therefore has to be updated really often - which I was not willing to do and also didn’t had the time for to do.
Also I still would have PHP Code which to be totally honest I don’t really like because it is really slow in comparison to Node.js or Go code.

My second thought was to implement my blog in Go. Yay! The response time would be amazing and I sure would learn a lot - given I only played around with Go so far.
But then again - a lot of overhead, fast out-of-date and time-consuming to maintain.

At first I was against static site generation.

I search a while and read a little bit more about static site generation and the more I thought about it the more it became clear to me: “This is the way to go.”

Static site generation was the key to the cons I had previously had against other solution. No security risks, because it is “only” HTML and no code is compiled on the server at runtime. No overhead - there are a lot of great static site generators out here and it would be - once set up - really fast to write articles and publish them.

I started with Nikola because it seemed like the perfect fit to me. It met all my requirements and also was very easy to install on ArchLinux (yaourt -S python-nikola-git).
So I headed right into it made a new git repo and nikola init to start a new Nikola instance.
Okay now let’s import my Wordpress posts.
I made exported my posts from within Wordpress thought a XML file and executed Nikolas built-in import method nikola import_wordpress posts.xml. Wow, that was easy.
Nope. Error. Damn it! DuckDuckGo to the rescue!
Okay installed Nikola from source on Github. Still that Error.
After a few hours of fumbling around I admitted defeat and moved on the the next generator on my list.

Eureka! Long story short I really didn’t like the way theming works in Pelican although I thought I could live with it, there where still some options on my list and I thought: “Better make sure you like it, because you will be using it for quite a while!”

Okay so I started on Picos website. Oh my.. PHP? Why? Oh boy, now I have to set up a complete web developing environment for a “simple” static site generator? Nah!
So I searched for lightweight Web-Servers for in-place use.
I discovered [node-sng][http://code.ravelsoft.com/node-sng] and thanks to Arch it was also easy to install.

But at this point I thought I just drop Pico because it is not practical for me and thus I wouldn’t use it for long.

Oh it looks kind of messy. The file header it not right. Okay I will go through my posts I also need to change some image urls and stuff.
Nice auto-compile function! While we’re at it let’s also install a nice theme.

Here are some useful code-blocks:

Conclusion

Although it was quite some time editing 60+ posts I really like the result and you may like it too! I’m really glad I took the journey to discover Jekyll.

I hope I gave you some insights in my journey and maybe you can save yourself some trouble and fist try Jekyll before you end up digging through the entire internet to find a static site generator you like.