Automatic Blog Translations With Claude and GitHub Actions

Every post I write gets translated automatically. Claude handles the translation, commits the results to main, and the translated versions deploy alongside the original.

The Flow

The translation workflow runs in GitHub Actions when English content is merged to main:

on:
  push:
    branches: [main]
    paths:
      - 'content/**/*.en.md'
flowchart LR
    B[Merge to main] --> C[Translations generated]
    C --> D[Committed to main]
    D --> E[Production deploy with all languages]

The Prompt

The workflow uses claude-code-action:

For each .en.md file that was added or modified:
1. Read the English content
2. Create translations for these languages: es, nl, de, it, fr, ja, zh, ru, hi
3. Save each translation as filename.{lang}.md (e.g., hello-world.es.md)
4. Preserve the frontmatter structure exactly, but translate the title
5. Translate the body content naturally
6. Keep code blocks, URLs, file paths, and technical terms unchanged

One prompt handles all 9 languages. “Translate naturally” produces more fluent output than “translate this text.” Code blocks and technical terms stay in English.

Handling Front Matter

Hugo posts have YAML front matter. Some fields should translate (title), some shouldn’t (date, slug):

“Preserve the frontmatter structure exactly, but translate the title”

English:

---
title: "Hello World"
date: 2025-12-20
draft: false
---

Hindi:

---
title: "नमस्ते दुनिया"
date: 2025-12-20
draft: false
---

The Commit

The workflow sets up a bot identity and constrains what Claude can do:

- name: Setup git identity
  run: |
    git config --global user.email "claude[bot]@users.noreply.github.com"
    git config --global user.name "claude[bot]"

- name: Translate with Claude
  uses: anthropics/claude-code-action@v1
  with:
    claude_args: "--allowedTools 'Write,Bash(git:*)'"
    prompt: |
      ...
      Use `git add`, `git commit`, and `git push` to add the translations directly to main.

--allowedTools limits Claude to writing files and running git commands.

Quality

Good enough for a personal blog. Claude’s translations are fluent and capture meaning well. A native speaker would catch occasional awkward phrasing, but it’s better than I could do myself.

Other Uses

The same pattern works for documentation generation, changelog summarization, commit message writing, and release notes:

  1. Detect what changed
  2. Send content to Claude with instructions
  3. Commit results back to the branch