This is it! After some thoughts, I decided it was time for me to finally open a tech blog, so that my article ideas may become concrete. After a couple of days hacking to produce something I am not ashamed of showing to the public, it is now online, ready to receive some content. I really do hope I will take the time to fill it, and also hope that the content will be worth reading. To inaugurate this blog, let's start with a post that describes what technologies I chose to host this content. # What about the content? Posts will be about technical thought I have, open-source projects I am working on, proofs of concept, and probably many other matters. As an open-source enthusiast, I chose an open license for the content (namely the [CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/), see the badge on the left) and you will be able to download the source of every article by clicking on the View source link on the upper right corner of each post. This is also an opportunity for me to try my idea of a blog where posts are written using the [literate programming](https://en.wikipedia.org/wiki/Literate_programming) paradigm from time to time. This is not the case for this post, but probably more to come on that matter… Even though I am not entirely convinced for now, comments are available on posts. This is an experiment of mine, and I may choose to disable them either entirely or for some selected posts if I get to much spamming and trolling. I know, for that to happen some visibility is necessary, but who knows? This blog is also entirely self-hosted, there is no call to external CDN or analytics server, you are not tracked by some social network badges, all requests made on this blog pages target my personal domain name. Of course, should you notice this is not the case, constructive feedback is always welcome in the comments to improve that. Comments are also hosted on my own server, more on that in the next section. My goal is to share knowledge without selling data of my visitors to some company. That being said, let's dive into technical stuffs. # Technical details Starting a tech blog was also an opportunity for me to discover new technologies or to update my lacky knowledge on other ones. ## The engine In the past I have been using [Jekyll](https://jekyllrb.com/) and [TiddlyWiki](https://tiddlywiki.com/) for similar blogging purpose, but they both have caveats I wanted to avoid here. Jekyll is well-established, has a big community, a lot of plugins, etc, but I always get frustrated when using it because my needs relentlessly end up not being how Jekyll wants my site to be done. I found it quite a hassle to extend Jekyll so that new processing steps are performed when compiling my site. TiddlyWiki is really interesting when I need to build a website that resemble a mind map, or when each part of the content is intrinsically tightly linked to other parts. Of course, TiddlyWiki is a really nice [quine](https://en.wikipedia.org/wiki/Quine_(computing)), well-architectured, quite easy to hack and extend, but this is not what I need here. A simple blog does not need all the flexibilty TiddlyWiki offers. Adding to that the fact that I wanted to take a travel outside my comfort zone, I decided to go for [nanoc](https://nanoc.ws/). This static site generator has several advantages and an interesting approach: - it is written in ruby, and I like that language for scripting; - it is simple at its core, does not presume what you want to do and how you should build your website; - it has a good documentation and a simple interface; - it comes with a handful of filters and small helpers and makes it really easy to add new ones; - its concept of compilation, layouting, and routing rules is what I needed; - deploying the blog is really easy. Of course this list is not exhaustive, nor is it objective. ## Customizations The fact that blogging features are not part of the core of nanoc is great because you can do it your way. Of course this comes at a cost: you must hack to tailor nanoc to your needs. **But**, nanoc being designed to be hacked, this is done easily. The main features I wanted to have for this blog are: - posts organized by date in the result, but not in the sources (I do not want to rename or move my source file if I change the publish date); - possibility to download the source of each post (will comes in handy for posts written in literate programming); - concept of sagas, where several posts are different episodes in the saga, and with a ToC to navigate between the episodes; - the possibility to process different input format at different stages of the compilation. The first point is achieved by the routing rules of nanoc. ```ruby route '/posts/*' do date_path = item[:created_at].strftime("%Y/%m/%d") "/posts/#{date_path}/#{File.basename(item.identifier.without_ext)}/index.html" end ``` My posts live in a directory named `posts`, and the _frontmatter_ contains a `created_at` metadata that contains the publish date (the name is the one required by the [`Blogging` helper](https://nanoc.ws/doc/reference/helpers/#blogging), even though I would have preferred a `published_on` metadata). The above routing rules makes it possible to create a target directory structure with the creation date of each post and takes the source file name has post identifier. If I decide to change the publication date, all I have to do is to modify the metadata accordingly, not move or rename the post source file. For what concerns the possibility to download a post source code, I am taking advantage of the preprocessing code blocks of nanoc rules. ```ruby preprocess do # create raw version of the articles articles.each do |article| date_path = article[:created_at].strftime("%Y/%m/%d") raw_id = "/raw/#{date_path}/#{File.basename(article.identifier)}" article.attributes[:raw_id] = raw_id @items.create(article.raw_content, {}, raw_id) end end ``` For each article a new nanoc item is created, which lives in the `raw` directory. Creating a new item in the preprocessing phase, makes it possible to use the [`LinkTo` helper](https://nanoc.ws/doc/reference/helpers/#linkto) to create links to the source in the article, without having to bother how this will be mangled by nanoc. For my sagas, I wrote a small helper called `Sagafyer`. ```ruby module Sagafyer def saga_toc(article) if article[:saga] and article[:episode] saga = article[:saga] episode = article[:episode].to_i episodes = articles.keep_if { |a| a[:saga] == saga }.sort_by! { |a| a[:episode].to_i } if episodes.length > 1 then toc = episodes.each_with_index.map do |ep,i| "