← Til baka

How to Automate Social Media Previews for Your Blog in 2026

· 5 mín lestrartími · Almennt

The Social Preview Problem

Every time you publish a blog post, you need:

Doing this manually for every post wastes hours. Here's how to automate all three with free APIs.

Step 1: Auto-Generate OG Images

Instead of designing images in Canva, use a dynamic URL that generates them from your post title:

<meta property="og:image" 
  content="https://og.pandan.is/v1/og?title={{post.title}}&subtitle={{post.date}}&color=%230070f3" />

Every post gets a unique, professionally styled preview image. Zero design work.

Step 2: Auto-Shorten Links

Before sharing on social media, create a short link that tracks clicks:

const response = await fetch('https://s.pandan.is/v1/shorten', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    url: `https://myblog.com/posts/${post.slug}`,
    alias: post.slug
  })
});
const { short_url } = await response.json();
// Share short_url on social media

Step 3: Auto-Generate QR Codes

For presentations, print materials, or conference talks, generate a QR code linking to each post:

const qrUrl = `https://qr.pandan.is/v1/qr?data=${encodeURIComponent(shortUrl)}&size=400&format=png`;
// Use in print layout or slides

Putting It All Together: A GitHub Action

Here's a GitHub Action that runs after every blog deploy:

name: Social Media Automation
on:
  push:
    paths: ['content/posts/**']

jobs:
  social:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Generate social assets
        run: |
          # For each new post, create short link + QR code
          for post in $(git diff --name-only HEAD~1 content/posts/); do
            TITLE=$(grep '^title:' "$post" | cut -d'"' -f2)
            SLUG=$(basename "$post" .md)
            
            # Shorten
            curl -s -X POST https://s.pandan.is/v1/shorten \
              -H 'Content-Type: application/json' \
              -d "{\"url\":\"https://myblog.com/$SLUG\"}" \
              > "social/${SLUG}-link.json"
            
            # QR code
            curl -s "https://qr.pandan.is/v1/qr?data=https://myblog.com/$SLUG&size=400" \
              -o "social/${SLUG}-qr.png"
            
            echo "Generated assets for: $TITLE"
          done

Cost: $0

All three APIs (OG Image, Link Shortener, QR Code) have generous free tiers:

For a blog publishing 4 posts per week, the free tier covers everything.

Get Started

Visit dev.pandan.is for interactive documentation and live demos of all APIs. Start automating your social media workflow today.