Translate Your WordPress Blog to Spanish & Boost SEO with SiteLocaleAI
Published on 2026‑07‑18
Overview
If you run a WordPress blog that attracts English‑speaking readers, you’re missing out on a massive Spanish‑speaking audience. SiteLocaleAI lets you self‑host a drop‑in JavaScript library that translates any page on the fly, localizes prices with psychological rounding, and—thanks to its CLI—pre‑renders fully translated HTML for search‑engine indexing. In this tutorial we’ll walk through the entire workflow:
- Install the SiteLocaleAI WordPress plugin (no Node.js required).
- Add the drop‑in JS library to your theme.
- Configure your LLM API key (Claude, GPT‑4o‑mini, etc.).
- Run the SEO pre‑rendering CLI to generate static Spanish pages.
- Verify that Google indexes the translated content.
By the end, your blog will serve Spanish readers instantly and rank for Spanish‑language queries.
Prerequisites
- A WordPress site (any version ≥ 5.9).
- An LLM API key (Claude, GPT‑4o‑mini, etc.) – SiteLocaleAI never stores your key.
- Access to your server’s command line (SSH) for the CLI step.
- Optional: a staging environment to test before going live.
Step 1 – Install the SiteLocaleAI WordPress Plugin
- Log in to WordPress → Plugins → Add New.
- Search for "SiteLocaleAI".
- Click Install Now → Activate.
The plugin adds a settings page under Settings → SiteLocaleAI where you can paste your LLM API key and choose target languages.
// Example: Adding the plugin’s settings link (optional)
add_filter('plugin_action_links_' . plugin_basename(__FILE__), function($links) {
$settings_link = '<a href="options-general.php?page=sitelocaleai">Settings</a>';
array_unshift($links, $settings_link);
return $links;
});
(Place the snippet in your theme’s functions.php if you want a quick link to the settings page.)
Step 2 – Add the Drop‑in JS Library
The plugin automatically enqueues a small script, but you can also add it manually for finer control.
// functions.php – enqueue SiteLocaleAI script
function enqueue_sitelocaleai() {
wp_enqueue_script(
'sitelocaleai',
plugins_url('dist/sitelocaleai.min.js', __FILE__),
[],
'1.0.0',
true
);
// Pass configuration to the script
wp_localize_script('sitelocaleai', 'siteLocaleConfig', [
'defaultLang' => 'en',
'targetLangs' => ['es'],
'apiKey' => getenv('SITELOCALEAI_API_KEY'), // keep it out of source control
]);
}
add_action('wp_enqueue_scripts', 'enqueue_sitelocaleai');
The library reads siteLocaleConfig and automatically translates any element with the data-translate attribute. For a typical post, you can wrap the content:
<article data-translate>
<?php the_content(); ?>
</article>
Step 3 – Configure LLM API Keys
- Go to Settings → SiteLocaleAI.
- Paste your API key into the LLM API Key field.
- Choose Spanish (es) as a target language.
- Save changes.
The plugin stores the key in the WordPress options table (encrypted with the site’s salts). No third‑party server ever sees the key.
Step 4 – Enable SEO Pre‑rendering with the CLI
Search engines struggle with client‑side translation. SiteLocaleAI’s CLI crawls your site, renders the translated HTML, and writes static files to a public_es/ folder that you can serve via your web server or a CDN.
# Install the CLI globally (Node.js required only on the build server)
npm i -g @sitelocaleai/cli
# Run the pre‑render for Spanish
sitelocaleai prerender \
--source https://yourdomain.com \
--lang es \
--output ./public_es \
--api-key $SITELOCALEAI_API_KEY
What happens under the hood:
- The CLI fetches each post URL.
- It injects the SiteLocaleAI script, forces es locale, and captures the fully rendered HTML.
- Prices are localized with psychological rounding (e.g., €9.99 → €10).
- The output folder mirrors your original URL structure (/2024/06/awesome-post.html).
Deploy the pre‑rendered files
If you’re on Apache or Nginx, add a rewrite rule:
# Nginx example
location /es/ {
try_files $uri $uri/ /public_es$uri.html =404;
}
Now https://yourdomain.com/es/2024/06/awesome-post.html serves a static Spanish page that Google can index directly.
Step 5 – Verify Indexing
- Use Google Search Console → URL Inspection and submit a Spanish URL.
- Check the Coverage report for “Indexed” status.
- In the page source, you should see the translated HTML, not just the JavaScript loader.
If you see the translated meta tags (<title>, <meta name="description">) in Spanish, you’re good to go.
Tips for Better Spanish Localization
- Glossary overrides: Add a
glossary.jsonfile to the plugin folder to force specific translations (e.g., brand names). - Currency formatting: SiteLocaleAI automatically converts USD to EUR or MXN based on the visitor’s IP. You can fine‑tune rounding rules in
settings → Price Localization. - Content freshness: Schedule the CLI to run nightly via a cron job so new posts are instantly pre‑rendered.
- Schema markup: The library preserves JSON‑LD schema, but you may want to translate
@descriptionfields manually for richer snippets.
Conclusion
With just a few clicks and a short CLI command, your WordPress blog can serve Spanish readers instantly, show culturally‑appropriate prices, and appear in Spanish search results. Because the translation happens on your own LLM API key, you retain full control over data privacy and cost.
Ready to boost your WordPress SEO? Try SiteLocaleAI today and watch your international traffic grow.