This blog is built using Pelican, a Python-based static site generator. It is hosted on Cloudflare Pages.
I am lazy and prefer to have as little barrier for entry as possible when working on tech projects, especially when writing. Using Pelican allows me to write each article in Markdown syntax from any device with a simple workflow of "upload Markdown file to a folder in a GitHub repository". This then triggers an automatic preview deployment, and then an automatic production deployment when the branch is merged.
Easy.
Setup
Cloudflare Pages was released back at the end of 2020. Pages is a Jamstack hosting service that enables automatic deployment of site builds based on deploy hooks. which allows you to run your site builds and deploy them on to the Cloudflare Pages service. It should be noted that Pages supports other static site generators such as Hugo and Jekyll too.
Jamstack comes from "JavaScript, APIs, and Markup" (JAM).
A Pelican-based Pages resource can be set up by following these steps:
- Sign in into Cloudflare.
- Navigate to Pages.
- Sign in to GitHub.
- Select an existing GitHub repository to connect to a Cloudflare Pages resource. This will be referenced for deployment.
- Populate the requested details, including build configuration. My Pelican build command is
pelican content
and build output directory isoutput
. I also set the environment variablePYTHON_VERSION
to the latest Python 3 build that I am using at the time (e.g. 3.9).
Deployment
When connected to your git source, Pages allows you to control which environments and branches you would like to automatically build. By default, Pages will trigger a build any time you commit to either your production or preview environment. You can view the production and preview deployments via a unique URL (with access controls if you want additional security). It is possible to configure automatic deployments to suit your preference on a per project basis.
Workflow
When I wish to make any changes to my blog, I do the following:
- Create a branch.
- Perform my changes (new articles, modify existing files, etc) and check-in. This triggers a new preview build in Cloudflare Pages that I can view and make sure i'm happy with the changes.
- Create a Pull Request and merge to "working" branch (that is my "proper" preview branch).
- When I want a new production release, I create a Pull Request to merge "working" to "main". This triggers a new production build.
Conclusion
I customised the blog with a few additional items like a custom theme, but this write-up should provide the gist of how to create something like this blog for yourself.
Efficiency through laziness.