Lo-Fi Python

Jul 28, 2021

8 Promising Python Static Site Generators

A static site generator creates static HTML and markdown files to serve as a website. They're commonly used to host blogs but not exclusively. I recently researched my options to roll a static site in Python. I'm assessing a few of them as a potential future self-hosted blogging solution for this Wordpress blog. Or maybe I'll spin up a new one!

Why Statics?

Most "modern" websites are dynamic in the sense that the contents of the site live in a database, and are converted into presentation-ready HTML only when a user wants to see the page. That's great. However, it presents some minor issues that static site generators try to solve.

In a static site, the whole site, every page, everything, is created before the first user even sees it and uploaded to the server as a simple folder full of HTML files (and images, CSS, etc).

The Nikola Handbook - https://getnikola.com/handbook.html#why-static

Static Site Generator Python Libraries

listed in largest to smallest order by # of Github project stars

Pelican | Github - 11K Stars

Seems to be the front running static site generator in Python's ecosystem. It contains a convenient pelican-importer tool to import existing content from WordPress, Dotclear, or RSS feeds. Enjoying the modular nature of the pelican-plugins and pelican-themes!

Lektor | Github - 3.5K Stars

Intriguing CMS project touting a "Python API", plugins for tools like Webpack and talented maintainers including the author of Flask.

Cactus | Github - 3.5K stars

"Simple but powerful static website generator using Python and the Django template system... typical users would be designers that are tech-savvy, want to use templates, but don't like to mess with setting up django or S3." (Mac OS) Demo Video

Nikola | Github - 2.2K stars

Viable option to host your site with the informative Nikola Handbook walking you through each step. Plugins for Jupyter Notebooks, post processing filters, a Wordpress importer command line tool and about 40 ready to go themes to find the perfect style.

Makesite | Github - 1.6K Stars

Offers less configuration, using only a single makesite.py file.

Hyde | Github - 1.6K stars

Port from Jekyll, a Ruby static site generator. It has since formed its own "evil twin" identity.

Mynt | Github - 400 stars

"Designed to give you all the features of a CMS with none of the often rigid implementations of those features."

Staticjinja | Github - 250 Stars

"Minimalist Python library for building static websites with Jinja."

Additional Resources

Update! I launched a Pelican blog about investing with Cloudflare pages. It's my first live static blog. Read more about it here.

Mar 03, 2016

Starting to Almost Kinda Think About Creating a Web App

One of my first goals when I started learning Python was to build a web application. Once you've gotten a basic grip on Python, you might be ready to learn about web frameworks. A web framework consists of software designed to aid in web development. They make it easier to create a website or web app - if you know how to use them. Unfortunately, there is a learning curve to using the frameworks but thankfully there is plenty o' documentation to go around to help you.

Here are the two Python Frameworks I've chosen to investigate:

  • Django - widely used, great community support, comes with just about everything built in. Can be used for smaller apps or multi-page/app websites.
  • Flask - a "microframework" used for smaller apps. Possibly more manageable for someone beginning a smaller project (me!)

So as a beginnerish-level coder, I've chosen to start with Flask; I also found this sweet guide that I think will help. Maybe someday I will graduate to Django, it sounds like a great framework. I've also decided that first I need to brush up on my HTML - And according to a lot of what I've read it doesn't hurt to know CSS/Javascript. So this whole "build a web app" idea will continue, albeit with some hurdles to clear first.

Edit: I ended up choosing web2py, which I hadn't even considered when I wrote this originally! Here's a post about why I chose it.