Tutorial

Auto-translate Ghost Blog Posts into 8 Languages

Published October 21, 2026

Auto-translate Ghost Blog Posts into 8 Languages

Auto‑translate Ghost Blog Posts into 8 Languages with SiteLocaleAI

Published on 2026‑10‑21

International audiences are the lifeblood of a growing blog, but translating each post manually is a massive overhead. SiteLocaleAI removes that friction by letting you self‑host a tiny JavaScript library that calls your own LLM API (Claude, GPT‑4o‑mini, etc.) and a CLI that pre‑renders translated pages for search‑engine indexing. In this tutorial we’ll turn a standard Ghost installation into a multilingual powerhouse that automatically creates SEO‑friendly versions in English, Spanish, French, German, Italian, Portuguese, Japanese, and Russian.


1. Prerequisites

Requirement Why it matters
Ghost 5.x (self‑hosted) Provides webhooks for post creation
Node.js 18+ (for CLI) Needed to run the SiteLocaleAI pre‑render script
LLM API key (Claude, GPT‑4o‑mini, etc.) Powers the translation engine
Domain with HTTPS Required for search‑engine indexing

2. Install the SiteLocaleAI JS library

SiteLocaleAI is framework‑agnostic, so you can drop it into any Ghost theme.

<!-- Add this just before the closing </body> tag of your default.hbs -->
<script src="https://cdn.sitelocaleai.com/v1/site-locale-ai.min.js"></script>
<script>
  // Initialise with your LLM endpoint and target languages
  SiteLocaleAI.init({
    apiKey: "YOUR_LLM_API_KEY",
    provider: "openai", // or "anthropic"
    languages: ["es", "fr", "de", "it", "pt", "ja", "ru"],
    rounding: true // enable psychological price rounding per currency
  });
</script>

Tip: If you prefer to host the script yourself, download site-locale-ai.min.js from the docs and serve it from your CDN.


3. Hook Ghost to trigger translation on publish

Ghost emits a post.published webhook. We’ll create a tiny Node server that receives the payload, calls the SiteLocaleAI API, and writes the translated Markdown files back to the Ghost content folder.

// server.js
const express = require("express");
const fetch = require("node-fetch");
const fs = require("fs");
const path = require("path");

const app = express();
app.use(express.json());

app.post("/webhook/ghost", async (req, res) => {
  const { post } = req.body;
  const { title, html, slug } = post;

  // Prepare translation request
  const body = {
    model: "gpt-4o-mini",
    messages: [
      { role: "system", content: "Translate the following blog post into 8 languages, keep HTML tags intact, and round any prices to the nearest psychological value for each currency." },
      { role: "user", content: `Title: ${title}\n\n${html}` }
    ]
  };

  const response = await fetch("https://api.openai.com/v1/chat/completions", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify(body)
  });

  const data = await response.json();
  const translatedHtml = data.choices[0].message.content;

  // Write translated file (Ghost reads from /content/posts)
  const outPath = path.join(__dirname, "content", "posts", `${slug}.${"es"}.md`);
  fs.writeFileSync(outPath, `---\ntitle: ${title} (ES)\n---\n${translatedHtml}`);

  res.sendStatus(200);
});

app.listen(3000, () => console.log("Ghost webhook listener running on :3000"));

Add the endpoint to Ghost’s Integrations → Webhooks panel:

URL: https://yourdomain.com/webhook/ghost
Event: Post published

Now every time you publish a post, the server writes eight translated Markdown files (one per language) into the content folder. Ghost will automatically serve them at /{lang}/{slug}.


4. Pre‑render translated pages for SEO

Search engines can’t execute JavaScript on every request, so we use the SiteLocaleAI CLI to generate static HTML snapshots that are served to crawlers.

# Install the CLI globally (requires Node 18+)
npm i -g @sitelocaleai/cli

# Run the pre‑render step for all languages
site-locale-ai prerender \
  --src ./public \
  --out ./public \
  --langs es,fr,de,it,pt,ja,ru \
  --api-key $OPENAI_API_KEY

The CLI crawls each URL, fetches the translated content via the JS library, and writes a static HTML file (/es/your-post/index.html, etc.). Deploy the public folder to your CDN or static host, and configure your web server to serve the pre‑rendered file to bots (via User‑Agent: * detection) while regular visitors still get the dynamic version.


5. Verify SEO indexing

  1. Google Search Console – Submit the language‑specific URLs (https://yourdomain.com/es/your-post/).
  2. Inspect URL – Ensure the rendered HTML contains the translated <title> and <meta description> tags.
  3. Schema.org – SiteLocaleAI automatically injects hreflang tags for each language, helping Google understand the language targeting.

6. Price localization (optional)

If your blog includes product mentions, SiteLocaleAI can round prices to the most appealing figure per currency (e.g., €9.99 → €9.95). Enable it in the init call:

SiteLocaleAI.init({
  apiKey: "YOUR_LLM_API_KEY",
  provider: "anthropic",
  languages: ["es","fr","de","it","pt","ja","ru"],
  rounding: true,
  currencyMap: { USD: "$", EUR: "€", JPY: "¥" }
});

The LLM will replace any $12.00 with the appropriate local format and apply psychological rounding.


7. WordPress plugin alternative (if you ever migrate)

SiteLocaleAI also ships a WordPress plugin that requires no Node.js. The same API key and language list are configured via the admin UI. This is handy for teams that run a hybrid Ghost‑WordPress setup.


8. Wrap‑up & next steps

You now have a fully automated pipeline:

  • Publish a post in Ghost → webhook triggers translation.
  • Store translated Markdown files alongside the original.
  • CLI pre‑renders static HTML for each language.
  • Search engines index the translated pages, boosting international traffic.

For deeper customisation (custom prompts, price‑rounding rules, or integrating with e‑commerce data), see the SiteLocaleAI Docs:


🎉 Try SiteLocaleAI today

Ready to make your Ghost blog truly global? Sign up for the $5 Indie plan and get instant access to the library, CLI, and full documentation. Deploy in minutes, and watch your international SEO soar.

Start translating now →