I’ve always liked Instagram for taking and sharing photos with quite a few now up on my profile. A couple of weeks back I got to wondering how I could get them into this blog. With Hugo this is pretty simple, it has an inbuilt shortcode which does all the work for you if you pass it in a photo ID.

  {{< instagram BuTYsdHAx_W >}}

Is all you need in a post and the shortcode will do the rest (see an example here).

Old Posts

That all seems pretty simple, so its just a job of pulling all my old posts from Instagram and making new posts for them in the right places in my timeline of blog posts. I turned to Python for this and the InstagramAPI package, that made it pretty trivial to pull out the caption, date and photo id for each of my old posts, then I used pystash to render a little template of each post with all the fields and save it into the tree of posts.

The code is pretty hacky, but if anybody wants a copy please drop me a line (my email is in the footer).

New posts

While that took care of the old posts, I wondered about how to handle new posts. I’m still now 100% on this, but I’ve rigged up a ifttt ‘app’ which posts to a web hook on my server whenever a new instagram post is made. That then tries to render the same template I used for the old posts and git commit and publish the site. We’ll see how that goes, there are too many moving parts in that for my liking, but we’ll see :)


For now, you can see all my old Instagram posts by checking out the category.