Gist – WordPress Sync

This is a tale of how this very section – works.

I ❤️ Gists, and I have a habit of posting small stuff/code/discoveries/guides etc. up there so I can revisit them later. (All of my public gists :

Additionally I use Gistbox, which allows me to categorize/add labels to my gists and find search through them faster.

But not all my gists are important, and most of them aren’t useful for other people, so I wanted to archive all the ones that could be potentially useful for others at

Problems and Solutions

This could have been solved easily by creating a Jekyll repository at Github, and posting stuff there in markdown, but I like being able to have separate Gist repositories for separate things.

That too could be solved by writing a small script to sync my gists with the jekyll, but then
1. I’d have to port the WordPress theme/CSS/etc to a jekyll blog.
2. Redo changes to the theme header & footer every time it changed on the wordpress site.
3. I wouldn’t be able to keep multiple files in their own git repo for each ‘hack’.

Also, I’ve had bad luck with Jekyll (on docker on Windows) before.

The Original Solution

To do this, originally, I created a Python script which would go through all my gists, then all my WordPress posts, then compare if there were any gists that hadn’t been posted to WordPress yet, and post those.

The script searches for a #gistblog hashtag in the gist description to identify if a gist should be synced, the rest of the hashtags as passed on as WordPress tags, the remaining gist description is used as the WordPress post title.

As far as the post content itself was concerned, the script simply posted the gist url as the body of the WordPress post, and let wordpress handle the embedding.

It worked out pretty well actually! Here’s an example of what an embedded post looks like :

The Problem

There’s a big problem with this approach – SEO.

There’s a chance that Google cannot see/will not index the asynchronously loaded content of the gist.

Well, what’s the point of aggregating content for others, if other can’t find it when they need it?

Introducing Gist-Wordpress-Sync 2.0

The new approach is an iteration over the previous one, but with a couple of new features:

  1. The application now requests the raw content of each tagged gist, runs it though the Github Markdown Parsing API, and posts the rendered HTML content to WordPress as the post’s body.
  2. It stores the gist’s id and updated_at attributes as WordPress custom_fields with every post (to track and update posts).
  3. Abstracts configuration settings into a .settings file so the script can be easily configured for other blogs.

The biggest downside is that since WebHooks don’t work for Gists, the application has to be manually run when changes are made to Gists.

It is still very rough around the edges, and may require tweaking for it to fit your taste/preferences, and the configuration of your WordPress blog.

The repository is available here :

If you want to run this for your own blog and need any help, please feel free to open an issue.