SEO Pre-rendering with the CLI

Generate static HTML pages for every language so Google can index each version. Deploy to your CDN or server and rank in every market.

1

Install the CLI

Install the SiteLocaleAI CLI tool globally.

The CLI tool reads HTML files from a directory, sends each text node to your running SDK for translation, and generates static HTML files for each language. It reads configuration from a .sitelocaleai.json file in your project root:

Verify the installation:

Terminal

npm install -g sitelocaleai-cli

Terminal

sitelocaleai --version
# sitelocaleai-cli v0.1.0

.sitelocaleai.json

{
  "sdkUrl": "http://localhost:4000",
  "licenseKey": "slai_live_your_key_here",
  "locales": ["de", "fr", "es", "ja"],
  "defaultLocale": "en",
  "inputDir": "./dist",
  "outputDir": "./dist/i18n"
}

Terminal

sitelocaleai translate ./dist \
  --base-url https://example.com

# [==============================] 100%  (96/96 tasks)
# [sitelocaleai] Done. Translated HTML written to: ./dist/i18n

# Then generate sitemaps for all locales:
sitelocaleai sitemap ./dist/i18n \
  --base-url https://example.com

# [sitelocaleai] Wrote sitemap-index.xml + 4 locale sitemaps

Output structure

dist/i18n/
  sitemap-index.xml
  de/
    index.html
    pricing.html
    about.html
    blog/index.html
    ...
  fr/
    index.html
    pricing.html
    ...
  es/
    ...
  ja/
    ...
2

Generate Static Pages

Pre-render your site in every target language.

Run the translate command pointing at your HTML directory, then generate sitemaps:

The CLI will:

  • Discover all HTML files in the input directory
  • Translate each text node via your SDK for every target locale
  • Generate static HTML files with proper lang attributes
  • Add hreflang link tags for cross-language SEO
  • Create a sitemap index for all language versions

The output directory structure looks like this:

Terminal

sitelocaleai translate ./dist \
  --base-url https://example.com

sitelocaleai sitemap ./dist/i18n \
  --base-url https://example.com
3

Deploy to Your Server or CDN

Serve the pre-rendered pages alongside your main site.

Copy the generated files to your web server or CDN:

Configure your web server to serve the pre-rendered pages for the appropriate locales. Here is an Nginx example:

For CDN deployment (CloudFront, Cloudflare Pages, Vercel, Netlify), simply upload the output directory. The directory structure maps directly to URL paths.

Terminal

# rsync to your server
rsync -avz ./dist/i18n/ user@server:/var/www/i18n/

# or upload to S3 / CloudFront
aws s3 sync ./dist/i18n/ s3://your-bucket/i18n/

nginx.conf

# Serve pre-rendered pages for /de/, /fr/, etc.
location ~ ^/(de|fr|es|ja)/ {
    root /var/www/i18n;
    try_files $uri $uri/index.html =404;
}

# Serve the sitemap index
location = /sitemap-i18n.xml {
    alias /var/www/i18n/sitemap-index.xml;
}

.github/workflows/prerender.yml

name: Pre-render Translations

on:
  push:
    branches: [main]

jobs:
  prerender:
    runs-on: ubuntu-latest
    services:
      db:
        image: postgres:18-alpine
        env:
          POSTGRES_DB: sitelocaleai
          POSTGRES_USER: slai
          POSTGRES_PASSWORD: test
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v4

      - name: Start SDK
        run: |
          docker run -d --name sdk \
            --network host \
            -e DATABASE_URL=postgres://slai:test@localhost:5432/sitelocaleai \
            -e SITELOCALEAI_LICENSE_KEY=${{ secrets.LICENSE_KEY }} \
            -e LLM_API_KEY=${{ secrets.LLM_API_KEY }} \
            -e EXCHANGE_RATE_URL=https://open.er-api.com/v6/latest \
            ghcr.io/hiscore-ro/sitelocaleai-sdk

      - name: Wait for SDK
        run: |
          for i in $(seq 1 30); do
            curl -s http://localhost:4000/health && break
            sleep 2
          done

      - name: Install CLI & translate
        run: |
          npm install -g sitelocaleai-cli
          sitelocaleai translate ./dist \
            --base-url https://example.com
          sitelocaleai sitemap ./dist/i18n \
            --base-url https://example.com

      - name: Deploy to server
        run: |
          rsync -avz ./dist/i18n/ \
            ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/var/www/i18n/
4

Add to CI/CD Pipeline

Automate pre-rendering on every deploy.

Add a GitHub Actions workflow to pre-render pages automatically whenever you push changes:

This workflow runs after every push to main. It starts your SDK, waits for it to be ready, pre-renders all pages, and deploys the output to your server.

For other CI systems (GitLab CI, CircleCI, Jenkins), the pattern is the same: start the SDK, run the CLI, deploy the output.

.github/workflows/prerender.yml

name: Pre-render Translations
on:
  push:
    branches: [main]
jobs:
  prerender:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install -g sitelocaleai-cli
      - run: |
          sitelocaleai translate ./dist \
            --base-url https://example.com
          sitelocaleai sitemap ./dist/i18n \
            --base-url https://example.com
      - run: rsync -avz ./dist/i18n/ user@server:/var/www/i18n/

Your site is now SEO-optimized for every language!

Google will index each language version separately, driving organic traffic from every market.