How This Blog Is Generated And Hosted


As I was preparing to take a sabbatical from work recently, partly to focus on writing again, I started to do some clean up and revitalization of this blog: I added HTTPS support, modernized the Javascript and CSS, removed quite a bit of unused JS and CSS, and improved how math is rendered on the blog. This post is a short note going over what I use to generate and host this blog, in case some of it might come in handy for anyone looking to setup a similar blog. If you need more details about anything, post in the comments below and ask.

Static blog generator

This blog is generated using Pelican which takes post and page content (written in .md, .rst, .html, etc. format) and uses a set of Jinja2 templates to generate all the needed files for a blog. This includes Atom feed XML files, pages for tags and categories, pagination, and everything else you normally get with a blog.

I picked Pelican back in 2012 mostly because it was written in Python, which is the language I am most efficient in. It is still adequate and I have not found enough reason to go through the effort of switching. However, if I were to start a similar blog from scratch I would likely look at more minimal and efficient solutions like Hugo instead.


I use Amazon S3 to host the output generated by Pelican and all the site's static assets that are not otherwise hosted by a CDN. Amazon S3 provides a relatively cheap solution for storage and hosting of static content. I then have Amazon CloudFront sitting on top of S3 as a CDN and cache layer, which also importantly enables me to use Amazon AWS Certificate Manager to enable HTTPS for the blog. CloudFront also adds gzip compression for most of the blog's content, assuming the visitor's browser supports it.

Amazon has a nice guide on how to setup HTTPS with CloudFront.

Comments on posts

I use Disqus to allow commenting on posts. Disqus allows simple commenting on posts (and pages, wherever you choose to enable it really), and simple tools to delete spam and moderate comments.

Math in posts

I used to use MathJax to render mathematical symbols and equations on this blog. Recently however, I learned about KaTeX which supports a subset of LaTeX but renders quite a bit faster than MathJax, at least based on this comparison.

More importantly, KaTeX can be run offline to produce the output HTML/SVG in advance. Noticing this, I wrote a simple Pelican plugin to process the HTML output of Pelican after successful blog generation and to use KaTeX to process LaTeX expressions and replace them with rendered HTML/SVG. You can find the plugin on GitHub at sahands/pelican_katex although it still needs some cleaning up and optimizing to be user friendly.

Offline rendering of the math during blog generation significantly improves the loading and scroll performance of math-heavy posts and eliminates the need for blog visitors to load KaTeX Javascript files at all. You can see it in action by going to any of the posts with significant math in them, for example this post on recurrence relations.