Rewrite Hugo Themes Report in Python

Ranking Hugo Themes by Stars, Commit Date

A while back I was grazing the selfhosted subreddit, and noticed Hugo coming up in conversation. I recalled that hugo requires a third-party theme in order to function. But was a bit of a challenge, because how do you know what is a good Hugo theme?

First Version in Bash

I ended up writing a little bash script (now deprecated) that scrapes the Github api and generates a little report about Hugo themes. It basically curled json from the Github api, and parsed it with grep, awk, and sed, and eventually spat out a plain text file.

Rewrite in Python

It was about a year later that I decided to rewrite the script in Python, using sqlite as a database. I discovered how to use the python requests module, got some practice with sqlite, and discovered how to make conditional request against the Github api using ETags and ‘If-Modified-Since’ (ETags are easier).

But this was my first time using python like this. And I have to tell you, it’s a lot moar fun than recursive fibonacci tutorials!

Building an HTML5 Table (bootstrap, actually)

By the time I had figured out how to collect the data I needed, I realized that I could simply generate an html table right in the python script.

rank_hugo_themes.py runs in a cronjob every night, and you can see view Hugo Themes Report here.

And you can see the script on Github.

Moving Sideways

I then went on to use the same system to create a report for myself about my personal stash of Arch AUR PKGBUILDS, and an unofficial Gentoo overlay, both of which I have (maintain?) for my own amusement. It saves quite a bit of time having an automatically generated table every morning showing which packages have been updated upstream.

Rewriting Again with Sqlalchemy

After listening to some back episodes of Talk Python To Me, I became aware of sqlalchemy. This sounded like something I should learn about, so I rewrote the script using sqlalchemy instead of the sqlite module.

What’s Next?

I guess now I can go back and spice things up with comments and tests, but there’s always tomorrow right? But that also leads to the question of how/why I started this blog.

Using Hugo Themes Report

Ironically, I never intended to use Hugo as a blogging platform. I was happy with mkdocs for documentation. But static blogs are easy, and so I began looking over the options.

I was hoping to use Pelican. But then I made an interesting discovery: Pelican has the same problem with theme ranking as Hugo does. And I haven’t created a Pelican Themes Report yet!

So I opened up Hugo Themes Report, found a theme that was reasonably popular and well-maintained that I like the looks of, which turned out to be MunifTanjim/Minimo, and am quite pleased with the result.

And I am also quite pleased that hugo is available as a snap package, although there are several other installation methods.