Automate Ghost Blog Multilingual SEO in 8 Languages
Published on SiteLocaleAI Blog
TL;DR – Install the SiteLocaleAI JS library, configure it with your LLM API key, add a tiny script to your Ghost theme, and run the sitelocale-cli to pre‑render translated pages for Google, Bing, and Baidu. The result: eight fully indexed language versions of every post, complete with localized prices and SEO‑friendly URLs.
1. Why a Self‑Hosted Solution?
Most translation plugins rely on third‑party SaaS, which adds latency, recurring costs, and limited control over data. SiteLocaleAI lets you self‑host the translation logic, using your own LLM API keys (Claude, GPT‑4o‑mini, etc.). This gives you:
- Zero per‑translation fees – you only pay for the LLM calls you already have.
- Full privacy – content never leaves your server.
- Fine‑grained schema control – you can enforce price rounding, date formats, and brand‑specific terminology.
2. Prerequisites
| Item | Version |
|---|---|
| Ghost | 5.x (or newer) |
| Node.js | 18+ (for the CLI) |
| LLM API key | Claude, GPT‑4o‑mini, etc. |
| SiteLocaleAI package | @sitelocaleai/translate |
3. Install the Library
Add the npm package to your Ghost theme (or any static assets folder). If you’re using a custom theme, run:
cd your-ghost-theme
npm install @sitelocaleai/translate --save
If you prefer a CDN approach, you can also load the minified bundle directly:
<script src="https://cdn.sitelocaleai.com/v1/translate.min.js"></script>
4. Configure the Translator
Create a small initialisation script that will be injected into every page. The script reads the LLM API key from an environment variable (never commit it to Git) and sets up the language map.
// public/js/sitelocale-init.js
import { SiteLocale } from '@sitelocaleai/translate';
// Pull the key from a server‑side rendered meta tag to keep it out of client JS
const apiKey = document.querySelector('meta[name="sitelocale-api-key"]').content;
const locale = new SiteLocale({
apiKey,
// Target languages – 8 of them
languages: ['es', 'fr', 'de', 'it', 'pt', 'ja', 'zh', 'ru'],
// Enable price localisation with psychological rounding
priceOptions: { round: true, currencyMap: { USD: '$', EUR: '€', JPY: '¥' } },
// Custom schema to keep headings, lists, and image alt‑texts intact
schema: {
headings: true,
lists: true,
images: { alt: true },
},
});
// Auto‑translate the article body once the DOM is ready
window.addEventListener('DOMContentLoaded', () => {
const article = document.querySelector('.post-content');
if (article) {
locale.translateElement(article);
}
});
Add the meta tag and script to your default.hbs (or equivalent) just before the closing </body> tag:
<meta name="sitelocale-api-key" content="{{env "SITELOCALE_API_KEY"}}">
<script type="module" src="/js/sitelocale-init.js"></script>
Tip: Ghost’s
{{env}}helper safely injects environment variables without exposing them to the client source.
5. SEO‑Friendly URL Structure
SiteLocaleAI automatically prefixes the language code to the path, e.g. /es/my‑post/. To make search engines understand this, add a <link rel="alternate"> block in the <head> of each post:
{{!-- default.hbs head section --}}
{{#post}}
{{#foreach languages}}
<link rel="alternate" hreflang="{{this}}" href="{{url}}/{{this}}/{{slug}}/" />
{{/foreach}}
{{/post}}
The languages array should be defined in your theme’s config.json:
{
"languages": ["es","fr","de","it","pt","ja","zh","ru"]
}
6. Pre‑Rendering for Search Engines (CLI)
Search bots often don’t execute JavaScript. SiteLocaleAI ships a CLI that crawls your Ghost site, renders each language version with a headless Chromium instance, and writes static HTML files to a dist/ folder. These files can be served via a CDN or your existing Ghost static assets pipeline.
6.1 Install the CLI globally
npm install -g @sitelocaleai/cli
6.2 Run the pre‑render command
sitelocale-cli render \
--site https://your‑ghost‑site.com \
--out ./dist \
--langs es,fr,de,it,pt,ja,zh,ru \
--api-key $SITELOCALE_API_KEY \
--headless true
--site– base URL of your Ghost blog.--out– destination folder for the static files.--langs– comma‑separated language codes.--headless– use headless Chromium for accurate rendering.
The CLI produces a folder structure like:
/dist
/en
index.html
/my-post
index.html
/es
/my-post
index.html
...
You can now point your web server (nginx, Apache, or a CDN) to serve /dist as the root. Search engines will crawl the pre‑rendered pages and index each language version separately.
7. Localising Prices with Psychological Rounding
If your blog includes product references or affiliate links with prices, SiteLocaleAI will automatically convert and round them to the nearest “psychological” value (e.g., $9.99 → $9.95). This is configured in the priceOptions object shown earlier. Here’s a quick example inside a post:
<p>Our premium plan costs <span class="price" data-currency="USD" data-amount="19.99">$19.99</span>.</p>
The library detects the .price class, fetches the appropriate exchange rate, and renders the rounded amount for each language.
8. WordPress Plugin (Optional)
If you also run a WordPress site, the same library can be used via the SiteLocaleAI WordPress plugin—no Node.js required. Install the plugin from the WordPress admin, paste your API key, and enable the “Ghost‑style” translation mode. This is handy for cross‑platform branding.
9. Testing & Validation
- Crawl the site with a tool like Screaming Frog to verify that every language URL returns a 200 status and contains the correct
<html lang="...">attribute. - Check the meta tags – ensure
og:localeandog:locale:alternateare set correctly. - Run a Lighthouse audit on a translated page to confirm fast load times (the static HTML eliminates the translation‑time penalty).
10. Going Live
- Deploy the updated Ghost theme.
- Set the
SITELOCALE_API_KEYenvironment variable on your server. - Run the CLI pre‑render step after each new post (you can automate this with a GitHub Action or a Ghost webhook).
- Submit the language‑specific sitemaps (
/sitemap_es.xml,/sitemap_fr.xml, …) to Google Search Console.
11. Wrap‑Up
You now have a fully automated, SEO‑ready multilingual Ghost blog that:
- Translates content on the fly with your own LLM.
- Renders static HTML for every language, ensuring search‑engine crawlability.
- Localises prices with psychologically rounded numbers.
- Works with any framework, thanks to the drop‑in JS library.
Start scaling your audience today—no extra hosting costs, no third‑party SaaS, just pure control.
Ready to try it?
Visit the SiteLocaleAI documentation to get the full reference, and spin up your first multilingual Ghost blog in minutes. 🎉
Happy translating!