Lo-Fi Python

Jul 08, 2022

Launching a Live Static Site Blog via Pelican, Github and Cloudflare Pages

Proud to announce my newest side project blog, Diversified Bullish, is live at divbull.com. It is made with Pelican and the Blue Penguin theme. I'm planning to write about stocks and investing there moving forward in addition to this blog which focuses on Python programming.

The divbull.com Github repo serves the static files generated by Pelican via Cloudflare pages. It's free, unless you purchase a domain. I purchased my .com domain with Namecheap before I learned about Cloudflare pages. I followed these instructions to set up my new financial blog. If you're interested, you can subscribe to an RSS feed here to follow when I post something new.

The dashboard provides a number of framework-specific presets. These presets provide the default build command and build output directory values for the selected framework. If you are unsure what the correct values are for this section, refer to Build configuration. If you do not need a build step, leave the Build command field blank.

https://developers.cloudflare.com/pages/get-started/

Cloudflare pages deployment details

Working in the Cloudflare pages build dashboard is sweet. It took me about 5 failed Pelican build commands to get the site to deploy. Finally, I was able to get the site build to complete by leaving the build command blank. Cloudflare was able to scoop up my Pelican "output" folder contents and render the blog. How cool. I feel like I've done the impossible, launching a passable quality blog with top shelf tools this quickly for under $10!

Initially, I spent a few hours getting to know Pelican. Once I correctly installed a theme I liked, I banged out a few philosophical financial musings to give the blog some posts. Then I had the static files generated but no clue how to serve them. Enter Cloudflare pages, a free option to host a blog.

Connecting the repo to Cloudflare pages, adding the files to the repo and finding the correct build command added a few more hours. In total, it took me about 1-2 days to make a live site since I did not know about Pelican or Cloudflare pages when I began playing with a Pelican blog in April. This was my first static site launch!

Cloudflare build settings

Generating a Blue Penguin themed Pelican blog.

showing Pelican blog workflow

Head over to divbull.com to see this Pelican, Github and Cloudflare pages stack in action.

Like static site generators? Check out this post about static site generator libraries in 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.