How I automated my technical blog SEO using Python and AI

Hi LeetCoders,

As I was grinding problems here, I realized that many of us are also building side projects or technical blogs to showcase our portfolio. One challenge I faced recently was maintaining a consistent SEO strategy for my niche site without spending hours on it.

I decided to treat this like a LeetCode hard problem: How to optimize metadata and image compression at scale?

I built a small Python script using the PIL library for WebP conversion and integrated an LLM API to generate SEO-optimized "Alt" tags based on image content.

Key findings from my automation:

Format Matters: Moving from PNG to WebP reduced my LCP (Largest Contentful Paint) by 40%.

Contextual Metadata: Using AI to generate descriptions for complex diagrams (like solar panel structures or circuit boards) helps significantly with Google Image ranking.

I’ve been testing this on my latest project about renewable energy efficiency: Estructura para Paneles Solares.

The script basically follows this logic:

Python
import os
from PIL import Image

def compress_image(source_path, target_path):
    with Image.open(source_path) as img:
        img.save(target_path, "webp", quality=80)
        print(f"Optimized: {target_path}")```

It’s a simple solution, but it freed up 5+ hours a week that I can now spend on system design practice.

Questions for you: Do you guys automate your portfolio's SEO? Or do you prefer using static site generators like Hugo/Jekyll that handle some of it out of the box?

Happy coding!

Comments (0)