Twarchive

Hugo themes for tweet archives

abandoned

Unfortunately, the Twitter API v1 deprecation broke the twarchive Python program which downloaded tweets. This means that it cannot add new tweets to an existing archive.

Tweets already downloaded will continue to work indefinitely. The Hugo themes will continue to work with already downloaded tweets.

I would like to fix this at some point, but I’m not that excited about it, so who knows.

twarchive is my project for making Hugo websites that contain archived tweets.

Embedded tweets look like this:

There is a comprehensive archive of all my tweets and more on a separate Hugo site at https://tweets.micahrl.com which may serve as a useful example.

The project source code is also on github fontawesome/brands/github mrled/twarchive, and the readme contains detailed install and usage instructions.

Goals

Implementation

This project has three main components:

twarchive Python program

The program understands Hugo sites, the Twitter API, and Twitter archives.

It can retrieve tweets from the Twitter API directly, and can also grab related tweets like thread parents, quote tweets, and retweets.

It can parse Twitter archive, and embed tweets without calling the API. This is especially useful for very old tweets, or if you have a tweet archive from a deleted account.

It can scan your Hugo posts for tweets embedded with twarchive’s shortcodes and download them or pull them from an archive, along with related tweets.

It works around Hugo’s limitation that it cannot generate a new page from data. Tweets are saved to JSON files inside Hugo’s data folder, but Hugo cannot create a page from data this way. The Python program creates a page for each tweet in the data folder instead.

ornithography

Each tweet is an iframe to a self-contained HTML file. Images and videos are base64-encoded data: URIs which are saved directly in the HTML.

Tweet styles are self contained and not affected by site styles. Dark mode is supported if the user has set prefers-color-scheme, but any site-specific toggles to enable dark mode like I have will not work.

Each tweet has a download button allowing for any user to easily make a copy of their own. Hat tip to Terrence Eden for explaining how this works.

aviary

A simple theme that can be used for a whole site.

I use it for https://tweets.micahrl.com.

Future work

Notes