New Blog Site

New Blog Site

Our new blog site is up and running!

So, what is going to be the best theme for the first blog if not to describe how this blog web site is set up!

Nikola, Git on Linux with Apache

This is the best way to set up your blog! Or just one way to do that of many other similar better or not. It all depends of your point of view. Or maybe not really proper or correct way at all. Either way, it seemed quite interesting to me and I had to give it a go.

Prerequisites are: Linux server (Raspberry Pi set up to be visible on the internet would do as well) Apache (I am sure it would work with other servers like nginx and others) git (and git repo) ability to run small script in crontab installed Pyton static site generator nikola

Git repo

For this site I created a private git repository on the same server (maybe in some of the following blogs there'll be more about how is that set up), but for public blogs github works well, too.

Currently it is set up in such way that my private repository is accessible by only authorised users which is not an issue for my local laptop where I have ~/.ssh/config set up to provide appropriate ssh key accessing the server. On the server itself I have checked out repository using only (file) path to the repo. Similarly, with github it would be the same for public repositories: they are accessible by anyone. In case of private repository stored somewhere else (not on the target server as for me) you would need to setup user and/or git in such way that repo can be accessed for reading.

So, next step was to check out the repository and install nikola's web site in that dir:


Nikola's get started document is pretty good and you can easily follow it. I recommend making a local site and playing around with it. At the end it boils down to couple commands:

$ nikola build


$ nikola serve --browser

Rest is matter of creating new files and directories in right places - like under posts. Since simple markup is what I decided to go I needed to change and add:

MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code', 'markdown.extensions.codehilite', 'markdown.extensions.extra', 'markdown.extensions.meta']

in order to allow simple set of metadata in my .md files. For instance, at the top of this document (called under posts directory) there is following:

Title: New Blog Site
Tags: Home, Blog, nikola
Date: 2018-05-04 16:22
Author: Daniel Sendula

Rest is pretty much the same markup used in .md files on the github.

Also, I tried to do it one thing at the time and each step is now separate commit in the git repo I created. And, believe me, it helps with this blog as I can go back using gitk and see all the changes I have done...

And, don't forget to craft your .gitignore file properly - you certainly don't want output dir being stored in git. For instance, here's my current version:


Nikola's themes

Of all themes I liked the matherial-theme the best. But not exactly in the shape it came from. Colours wise and some other tiny amendments were needed to set the right look and feel I wanted.

Theme itself was installed using:

nikola theme -u -i material-theme

since it lives in 'v8' place (opposite to 'default' 'v7') and got:

THEME = "material-theme"

Next was to change colours and some other css bits in themes/material-theme/assets/css/material.css and themes/material-theme/assets/css/theme.css. Such customisation is really up to everyone to do to the best of their abilities and preferences.

And last thing was to find a good way of making markup locally. So far I've got to VisualStudio Code + their markup visualisation (COMMAND+SHIFT+V) + Spell Right plugin.

Server Configuration

Back to the server. Directory web site is going to be is now checked out form the git repo with all the nikola stuff in. Initially run:

$ nikola build

in that dir and it will produce output dir where all static HTML pages live. So, all we need is to point apache to it. But, invoking the same command each time something has changed is a bit tedious. That's why I've created a script:


check_site () {
  cd $1

  CHANGED=1 && git pull  | grep -q 'Already up-to-date.' && CHANGED=0

  if [ "$CHANGED" == "1" ]
    echo "Rebuilding site $1"
    nikola build
    echo "No changes to $1"

check_site /srv/

As you can see, last line in the script can be repeated as many times as you want, pointing to different directories with different nikola sites.

That script is, in turn, invoked every 5 minutes by the cron daemon:

*/5 * * * * click /srv/nikola-update/

is the line in the /etc/crontab.

And now you can commit your changes to your first post and server will pick them up in less than 5 minutes (or exactly 5 if you are so unlucky to publish it exactly at the same time above script has run previously).

Also, don't forget to check your while site locally but running previously mentioned command:

$ nikola serve --browser


Comments powered by Disqus