Boost Your Hugo Blog with Automated Open Graph Images
前言 / Introduction 突然想讓自己的文章在分享的時候更酷炫,那就試試看 Open Graph (OG) 圖片,可以讓你的連結在 Discord、Twitter、LinkedIn 等平台上顯示精美的預覽卡片。 本文將教你:/ What you’ll learn: 設計 OG 圖片模板 / Design OG image templates 用 Playwright 自動生成圖片 / Auto-generate images with Playwright 整合 GitHub Actions / Integrate with GitHub Actions 自動化部署到 Cloudflare Pages / Deploy to Cloudflare Pages Step 1: Design an HTML Template 建立 og-template/template.html 作為 OG 圖片模板。標準 OG 圖片尺寸為 1200x630px。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <style> body { width: 1200px; height: 630px; margin: 0; display: flex; justify-content: center; align-items: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); font-family: 'Inter', -apple-system, sans-serif; color: white; text-align: center; padding: 60px; } h1 { font-size: 80px; font-weight: 800; margin: 0; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); } </style> </head> <body> <h1>{{TITLE}}</h1> </body> </html> Tips: ...