Animated pixel wizard

There's a slug in my source code!

Thursday, July 1, 2021

tl;dr: custom script which generates three word random strings are used for the article slugs on the site 🐌

At some point of browsing this website, you may have noticed that the articles have odd looking slugs1 attached to them (this very article has a pretty odd one!).

The style of slug I’ve chosen for this site is based shamelessly-ripped-off of the what.three.words location app, which uses three words to split the globe into three-worded-three-meter-squares.

Liking the idea and wanting to implement a similar solution myself, I decided on website slugs, hence gastropod🐌 was born.

On the technical side, gastropod🐌 uses the json and random modules built-in to Python (did I mention it’s a Python script) and a brilliant collection of words thanks to the english_words GitHub repository.

Reading in the words_dictionary.json file from said repo into a dictionary with the json.load function which parses a json string into a dictionary, from there it’s a case of psuedorandomly grabbing three words from the dictionary and stitching them together.

Future plans for gastropod🐌 are to include some checks to ensure the words_dict.json file exists and implement a solution to store and check if a slug has already been used or not.


  1. Not the slimy kind, the end part of the URL which points to a specific page or article e.g. example.com/i-am-a-slug/ ↩︎

From me to you.