Jekyll Blog Statistics: a Perl Program to Graph Them

The Problem

I like to report stats about my own blog, as you can see here. But how can I compute such stats? A few years ago I wrote a quick and ugly Perl script that allows me to count and generate some gnuplot files. The problem with such script is that it produces gnuplot files, then I have to run gnuplot to render some PNG images, move the images, edit the markdown page to insert the results and the images.
Long story short: it is too much work for my laziness to keep stats up-to-date!
That’s why I decided to refactor the script in order to let it do most of the work for me.

Introducing jekyll-simple-stats

jekyll-simple-stats is a repository you can find both on my GitHub and GitLab repositories.
The repository consists of a single Perl 5 script, that does the following tasks: 1) it scans the _posts_ directory reading all publishing dates and tags from every markdown post; 2) it builds a gnuplot file for every year with the amount of posts discriminated by month, then it produces a PNG file; 3) it builds a gnuplot file for main tags for each year (e.g., ten main tags) and provides a PNG graph; 3) it builds an html fragment file that can be included in another page using ‘include’ directive.

So what I’ve done so far is:
  • prepare a directory to contain all the images generated by the script;
  • include the generated html fragment in my statistic page.

My Workflow

Today, when I wish to update the statistics, I simply do the following steps.


The script infers directories and files by an home for the site, specified with the -h flag.
% perl -h ~/git/
The stats.html fragment is generated in the _include_ directory, the posts directory is based afte the home ~/git/ and the images are placed under the images/graphs directory, also rooted at the home one.

commit changes

Really, nothing else. Already has been already prepared.

There is room for improvements

Of course, jekyll-simple-stats being a two-hours project, there is a lot of room for improvements like adding custom flags, improve the graph generation where I’m totally a newbe, and so on.

In the case you would like to help me on this tiny project, feel free to submit an issue or a pull request!
In the meantime, I hope it can be helpful for you too!

The article Jekyll Blog Statistics: a Perl Program to Graph Them has been posted by Luca Ferrari on July 10, 2019