Everything I Automated on This Blog
说明与用途
使用 GitHub Actions 自动化 Hugo 博客在 Azure Static Web Apps 上的发布、图像生成、结构化数据、dev.to 跨发布和新闻稿草稿创建。
问题
Automating routine post‑publishing tasks for a Hugo blog hosted on Azure Static Web Apps to reduce manual effort and errors.
结果
The blog now publishes posts automatically, generates share images, inserts structured data, cross‑posts to dev.to, creates newsletter drafts, and exports Markdown, all without manual intervention, except for final newsletter sending and other social media posts.
工作流
- Configure GitHub Actions workflow with jobs for build, deploy, and post‑processing
- Use Hugo --buildFuture to allow future‑dated posts to be built
- Generate 1200x630 og.png images using Hugo image filters and TrueType font
- Create JSON‑LD BlogPosting block by serializing a Hugo dict and marking it safe
- Run Python script after build to cross‑post to dev.to via Forem API, handling canonical URLs, links, tags, series, and descriptions
- Create Buttondown newsletter drafts for new posts, with status draft
- Export each post as index.md alongside index.html and serve llms.txt
- Add workflow_dispatch trigger to allow manual re‑run of the workflow
- Exclude .md, .txt, .xml, .json from Azure Static Web Apps fallback to prevent MIME type issues
证据
Hugo skips any post whose date is in the future unless you build with --buildFuture.
Every page gets a 1200 by 630 share image rendered by Hugo itself, with no Puppeteer, no Node, and no image service.
My first version wrote the JSON by hand in the template and piped each value through jsonify:… That looks right and is wrong.
The deploy workflow has a job that runs after the build and calls a small Python script against the Forem API.
A second job watches for added posts and creates a Buttondown email for each, with the title and a link.
Every post is also published as index.md next to its index.html, from a four‑line template that emits the title, description, date and the raw Markdown source.
- 记录日期: 2026-10-16T15:55:58.547Z