// blog_post_python-blog-generator

Building a Simple Python Blog Generator

2025-01-16
pythonwebstatic-site

Building a Simple Python Blog Generator

After getting frustrated with Hugo's complexity, I decided to build my own minimal blog generator in Python. Sometimes the simplest solutions are the best ones.

The Requirements

I wanted something that could: - Convert Markdown to HTML - Use a consistent template for styling - Generate a blog index page - Automatically update my homepage with recent posts - Be simple enough to understand in 5 minutes

The Solution

The entire system consists of just two files: - generate_blogs.py - The generator script - blog_template.html - The template file

Key Features

Frontmatter Support: Each blog post can include metadata:

---
title: My Post Title
date: 2025-01-16
tags: python, web
slug: custom-url-slug
---

Automatic Homepage Updates: The generator automatically updates the homepage's blog section with the 3 most recent posts.

Math Support: LaTeX expressions are automatically detected and MathJax is loaded when needed.

Usage

  1. Write a post in blogs/my-post.md
  2. Run python generate_blogs.py
  3. Done!

The generator creates HTML files in public/blogs/ and updates the main homepage with recent posts. It's that simple.