Skip to main content

Responsive Images with Nikola

When you spend hours refining your blog theme to be tens of kilobytes then you add the first image and your page weighs more than 3 megabytes!

I enjoy photography - enough to invest in good equipment, post-processing software and years of practice. One part of testing out other static-site-generators was to see if I can incorporate my photos into the blog with less hassle so that I post regularly.

 Close up photo of Indian Moon Moth
  Close up photo of Indian Moon Moth

moon-moth-0.jpg by Harshad Sharma is licensed under CC BY-NC-SA 4.0

I admit that I didn't try too hard with Pelican, but I did struggle to make it serve responsive images. The experience with Zola was a breeze. And as I'm trying out Nikola, it took a bit of reading documentation of another library before I could write a plugin. It works, but it is not optimized for tens of thousands of images that I have in my archive, waiting to be posted. It is slow even with less than 20 images - and that's all my fault. I think I can fix it.

 Further close up of Indian Moon Moth.
  Further close up of Indian Moon Moth.

moon-moth-1.jpg by Harshad Sharma is licensed under CC BY-NC-SA 4.0

But I am surprised/disappointed that none of the static-site-generators that I have tried so far come with this feature as a part of its base / core or even as plugins. Zola was the closest with ability to resize images built into it. Nikola can generate a single thumbnail and that's it.

But that's alright, because it is working on this very post :-) Over the next few days I'll clean up the plugin and publish it. In the meanwhile, enjoy this soft and fuzzy moth :)

 Macro shot of Indian Moon Moth, showing its soft fuzzy wings.
  Macro shot of Indian Moon Moth, showing its soft fuzzy wings.

moon-moth-2.jpg by Harshad Sharma is licensed under CC BY-NC-SA 4.0

I have been releasing most of my photographs under Creative Commons license, and I plan to continue doing so. You can click on the caption below the photos for a link to download.

 Even further close up of Indian Moon Moth, showing the leaf-like structure of its green antennae.
  Even further close up of Indian Moon Moth, showing the leaf-like structure of its green antennae.

moon-moth-3.jpg by Harshad Sharma is licensed under CC BY-NC-SA 4.0