# Rewrite Hugo Themes Report in Python - Trent's Blog
Trent's blog of mostly technical documentations.

Skip to content

# Rewrite Hugo Themes Report In Python

date: 2019-01-25T01:02:57-08:00

## 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 view Hugo Themes Report here.

And you can see the script on Github.