Hybrid Architecture 3.0: How I Published the English Edition of My Blog with WordPress, Hugo, Python, and Gemini

Automated English translation of the original Spanish article. Code examples keep their original identifiers.

A decoupled publishing architecture, without multilingual plugins, powered by automated translation.

When you maintain a technical blog in Spanish for a while, sooner or later the same question arises: is it worth having an English edition?

The quick answer is usually yes. The problem is that the traditional implementation in WordPress can bring an extra layer of complexity: multilingual plugins, post relationships, duplicated editing interfaces, additional queries, and cache management that must take multiple language versions into account.

Plugins like WPML or Polylang solve a real problem and can be an excellent choice when you need to manage translations directly from WordPress. In my case, I preferred to explore an alternative that wouldn’t add that responsibility to the main application’s runtime lifecycle.

The idea was simple: WordPress would remain the single editorial source of truth for the Spanish content, while the English edition would be an independent static site, automatically generated with Hugo and synchronized via Python and the Gemini API.

This implementation doesn’t start from scratch. It is an evolution of the architecture I previously developed to automate the intelligence of my content Hubs, where I had already combined WordPress, Hugo, and external background processes to generate and publish static content.

You can read about the background in Hybrid Architecture 2.0: How I Automated the Intelligence of My Content Hubs.

In that version, the goal was to automate building technical Hubs. Now, I’m taking that same philosophy one step further: using a decoupled architecture to maintain a full English edition of my blog under /en/.

(Note: if you’re reading the English version of this article, you’re looking at the system running in production).

1. The Design: Separating Editorial Source from Publishing

Before writing a single line of code, two key decisions could not be left to chance.

URL Structure

I chose /en/blog/{year}/{slug}/, omitting the month and always keeping the trailing slash.

This structure maintains reasonable symmetry with /blog/, leaves /en/ open for a minimalist English homepage, and allows linking both versions via hreflang.

For example:

  • Spanish: https://juredev.com/blog/2026/12/mi-articulo/
  • English: https://juredev.com/en/blog/2026/my-article/

Each version has its own canonical URL and its own generated content.

Strict Separation of Concerns

Even though /temas/ and /en/ both use Hugo, they have different responsibilities.

The English project lives in its own directory:

/opt/juredev-en/

Its generated files deploy to:

/var/www/juredev-en/en/

It also has its own logs and uses a dedicated WordPress plugin (juredev-en-connector), completely independent of the Hubs connector.

This prevents a Hubs deployment from accidentally overwriting the English edition, or both projects from sharing processes that should remain isolated.

The Data Flow

The architecture has two main stages:

1. Initial backfill:

WP-CLI (post_date ASC)
   |
   v
HTTP 127.0.0.1:8088
   |
   v
BeautifulSoup + markdownify
   |
   v
Gemini API (JSON schema)
   |
   v
Gatekeeper
   |
   v
wp-{ID}.md
   |
   v
rewrite_links.py

2. Incremental synchronization:

cron (*/15 * * * * + flock -n)
   |
   v
reconcile_orphans()
   |
   v
post_modified_gmt != _en_last_synced_modified
   |
   v
SHA-256 (_en_content_hash)
   |
   v
translate_post.py (--max-posts 10)
   |
   v
hugo --gc --minify
   |
   v
rsync -a --delete-after
   |
   v
/var/www/juredev-en/en/

Each component has a concrete responsibility:

  • WordPress manages the original content.
  • Python orchestrates extraction, normalization, and synchronization.
  • Gemini handles the translation.
  • The Gatekeeper validates response integrity.
  • Hugo generates static HTML.
  • Nginx serves the English edition without touching PHP.

Translation is derived content, not a second independent editorial source.

This distinction is crucial: if I edit an article in Spanish, the process must detect the change and regenerate its English version.

2. The Nginx Layer: Three Pitfalls Worth Avoiding

Decoupling /en/ in Nginx looks trivial until you inspect the actual production server block.

Three important details emerged in my configuration.

2.1. The Internal 127.0.0.1:8088 Block

The public server on port 80 redirects everything via 301 to HTTPS. Over HTTPS, I have Cloudflare and FastCGI Cache, with a key based on:

$scheme$request_method$host$request_uri

If the extractor queried the public site, it could hit Cloudflare or receive a cached Nginx response after an article was edited.

The solution was adding a dedicated server block on loopback:

server {
    listen 127.0.0.1:8088;
    server_name juredev.com;

    root /var/www/juredev;
    index index.php index.html;

    location /blog {
        try_files $uri $uri/ /blog/index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        include snippets/fastcgi-php.conf;
        fastcgi_param HTTPS on;
    }
}

There are two important details here.

First, the server listens exclusively on 127.0.0.1, so it is never exposed directly to the Internet.

Second, fastcgi_param HTTPS on; makes PHP treat the request as HTTPS, even though the connection between the extractor and Nginx occurs over local HTTP.

This way, WordPress generates proper https:// URLs—including the corresponding data in JSON-LD—without passing through the public server.

This virtual host also lacks the FastCGI Cache configured on the public server. Consequently, the extractor bypasses both Cloudflare and that Nginx caching layer.

This doesn’t mean all possible application-level caching is automatically bypassed, but it does eliminate dependencies on the public infrastructure when fetching content.

2.2. The Global Static Regex and location ^~ /en/

In Nginx, a regex rule such as:

location ~* \.(css|js|webp|jpg|png)$ {
    ...
}

can take precedence over a standard location /en/.

If the English edition files reside in /var/www/juredev-en/en/, that global rule might look for CSS or images inside WordPress’s root and return a 404.

To avoid this, I use the ^~ modifier:

location = /en {
    return 301 /en/;
}

location ^~ /en/ {
    root /var/www/juredev-en;

    try_files $uri $uri/ =404;

    error_page 404 /en/404.html;

    location ~* \.(css|js|svg|woff2|jpg|jpeg|gif|png|ico|webp|avif)$ {
        access_log off;
        log_not_found off;
        expires 30d;
    }
}

The ^~ modifier stops regex matching at the same search level when requests match this prefix.

I also chose root instead of alias because it maps directly to the directory structure.

A request such as:

/en/blog/2026/my-article/

resolves inside:

/var/www/juredev-en/en/blog/2026/my-article/

It is clean and easy to maintain.

2.3. Zero Soft 404s

Another important detail is handling non-existent pages.

If you use:

try_files $uri $uri/ /en/404.html;

Nginx performs an internal redirect to the custom error page. That response can end up returning 200 OK, even though the content doesn’t actually exist.

For search engines, this turns into a Soft 404.

Instead:

try_files $uri $uri/ =404;
error_page 404 /en/404.html;

returns a true 404 while serving a custom template.

Here, there is an additional detail worth verifying: the error page path must resolve properly within the English edition directory. Furthermore, the final response must retain the 404 HTTP status.

For example, after deploying the configuration, you can verify it with:

curl -I https://juredev.com/en/ruta-inexistente/

The expected result is 404, not 200 OK.

The distinction matters: presenting a user-friendly error page is one thing; properly signaling to the HTTP client that the resource does not exist is another.

3. The Minimalist WordPress Connector (juredev-en-connector)

There is no need for heavy logic inside WordPress.

The plugin is roughly 220 lines long and handles three responsibilities.

Selective Exclusion

It provides a sidebar checkbox via the metadata field:

_skip_en_translation

This allows excluding a specific post when its content should not be translated.

By default, all published posts enter the pipeline, including the Opinión tag.

The latter is important so as not to break the internal link graph.

Injecting hreflang

Hooked into wp_head, the plugin injects language alternates whenever the metadata exists:

_en_translated_url

This way, Spanish pages can point to their English counterparts.

The implementation includes es, en, and x-default tags, maintaining reciprocal relationships between versions.

Here is an important SEO consideration: x-default designates the fallback page offered when no other language or regional version matches. It does not strictly have to be the original language, nor is there an absolute rule requiring the Spanish version.

In this project, Spanish is the original edition and works well as the default fallback. It is a decision tailored to this site’s design, not a universal law.

It is equally critical that references remain consistent and reciprocal: there is no point in advertising a translation that does not yet exist or has been unpublished.

EN Column in wp-admin

It adds an EN column to the post list table.

This provides a quick status overview for each article:

  • EN ↗: synchronized.
  • Pendiente: not yet translated.
  • Excluido: marked to skip translation.
  • Error: the last translation run failed gatekeeping/processing.

It is a small admin UX enhancement that lets you check the pipeline status without diving into logs.

Synchronization Metadata

The pipeline relies on several wp_postmeta fields to track state.

MetadataResponsibility
_en_content_hashSHA-256 of canonical content
_en_last_synced_modifiedGMT timestamp of the last successful sync
_en_slugFrozen English slug
_en_failed_hashHash of content that failed translation
_en_fail_countNumber of failed attempts for that hash

The hash is computed over canonical JSON containing:

  • Title.
  • Description.
  • Featured image.
  • Taxonomies.
  • Cleaned HTML.

This detects changes that might not live inside the article body itself.

The English slug is frozen after the first translation. That way, fixing a typo in the title months later won’t inadvertently alter the post’s canonical URL.

Finally, _en_failed_hash and _en_fail_count implement a retry policy bounded by hash.

If a translation fails three times for the same content hash, the cron stops retrying every fifteen minutes.

If the content changes later, the hash changes with it, allowing the pipeline to reprocess the post.

This isn’t a conventional circuit breaker—which typically manages closed, open, and half-open states to throttle service calls. Here, the mechanism is simpler: it avoids endlessly repeating failed processing for an unchanged version of content.

4. The Python Engine: Clean DOM, Protected Code, and Gatekeeper

The most common mistake when translating technical articles with an LLM is sending raw Markdown mixed with code or asking it to output YAML Front Matter directly.

Sooner or later, it will mess up indentation, mangle syntax, or introduce characters that break serialization.

That is why the pipeline in translate_post.py is intentionally deterministic.

4.1. DOM Extraction and Sanitization

The first operation extracts:

div.article-content

and strips elements that are not part of the article.

For example, the banner:

p.post-series

injected by the Hubs plugin.

The goal is to feed the translator only editorial, relevant content.

4.2. Code Shielding Before markdownify

This is one of the most critical decisions in the pipeline.

Rather than attempting to locate code blocks with regular expressions after converting to Markdown, every <pre> element is extracted directly from the DOM.

The process is:

  1. Find each <pre>.
  2. Save its raw text without modification.
  3. Replace the element in the HTML tree with a unique placeholder token.
  4. Convert the rest of the document to Markdown.
  5. Translate the content.
  6. Reinject the original blocks.

The placeholders look like:

[[SNIPPET_0]]
[[SNIPPET_1]]
[[SNIPPET_2]]

When rebuilding the document, the script dynamically calculates the number of backticks required to fence each block.

For instance, if the code contains three consecutive backticks, a fence of four backticks is used to avoid prematurely closing the block.

This mechanism prevents Gemini from ever treating source code as translatable text.

It is also worth distinguishing two aspects of code preservation.

Preserving the text inside code blocks protects syntax, indentation, and raw content. However, if we also need to preserve presentation metadata—such as class="language-php" or attributes used by a syntax highlighter—we must store those attributes separately and restore them when reconstructing the document.

Thus, code integrity and presentation metadata preservation are related, but distinct guarantees.

In a technical blog, preserving code isn’t an aesthetic preference: it is a core integrity requirement.

4.3. Deterministic Taxonomies

Categories and tags are handled via:

taxonomy_map.json

Each category or tag is translated once per slug, and the mapping dictionary is reused across subsequent posts.

This prevents a category like Desarrollo from showing up as Development one day and Software Dev the next.

Consistent taxonomies are also essential for keeping Hugo’s navigation structure clean and coherent.

4.4. Structured JSON with Gemini and Pydantic

Instead of requesting free-form text or YAML, Gemini returns a structured JSON object with defined fields:

{
  "title": "...",
  "description": "...",
  "slug": "...",
  "body": "..."
}

The integration uses google-genai and Pydantic to validate the response against a schema.

The final Front Matter is not generated by Gemini.

Python serializes it using:

yaml.safe_dump()

This avoids relying on the model to output syntactically valid YAML.

There is also a small detail that saves tokens: the top transparency disclaimer (“Automated English translation of the original Spanish article…”) and the footer discussion box linking directly to #comments on the original post (welcoming comments in English as well) do not need to be generated by Gemini.

Hugo’s single.html template renders both directly by reading es_url.

It is a deterministic task that makes no sense to delegate to an LLM, and it lets you update those callouts across all 112 articles instantly at $0 cost.

4.5. The Gatekeeper

Before writing the file:

wp-{ID}.md

the script runs a series of sanity checks.

Among them:

  • finish_reason == STOP.
  • Word ratio within a reasonable threshold.
  • Integrity of all code placeholder tokens.
  • Preservation of original image URLs.

These checks serve as an integrity barrier, not a semantic evaluation engine.

A normal STOP completion doesn’t guarantee the translation is accurate, complete, or captures every technical nuance.

Nor does a reasonable word count ratio guarantee high translation quality.

The Gatekeeper’s purpose is to prevent incomplete or structurally corrupted outputs from reaching the publishing pipeline.

Editorial review remains crucial, especially when translating articles with specialized terminology, code snippets, or explanations reliant on nuances of the source language.

5. Backfill, a $0 Second Pass, and Continuous Operation

The historical archive had 112 articles when I rolled out the system.

To process them, I ran a chronological backfill:

post_date ASC

The rationale is straightforward: when translating a newer post that links to an older one, the target post already has its English version ready.

Yet there is an edge case that chronological order alone cannot resolve.

What happens when an older article was edited later to add a link to a post that didn’t exist when the backfill began?

For that, I implemented:

rewrite_links.py

The Second Pass

This script traverses previously generated .md files and updates pending internal links to their English counterparts.

It does this without calling Gemini again.

The process:

  • Preserves Front Matter.
  • Leaves code blocks untouched.
  • Identifies internal links.
  • Queries the URL map.
  • Rewrites targets whenever an English translation exists.

If the target lacks a translation, the original link is preserved instead of generating a broken URL.

The Gemini API cost of this second pass is $0. Naturally, there is local CPU and execution overhead, but zero LLM inference is consumed.

Incremental Synchronization

Once the backfill was done, a 15-minute cron job keeps the English edition up to date.

The process runs via:

flock -n

This prevents overlapping runs.

The synchronization pipeline executes several stages:

1. Deletion reconciliation

If a post reverts to draft, is trashed, or is marked as excluded, the process deletes its matching file:

wp-{ID}.md

This ensures that an unpublished post disappears from the English edition.

2. Timestamp pre-filtering

It compares:

post_modified_gmt

and:

_en_last_synced_modified

If the post hasn’t changed since its last successful sync, it is quickly skipped.

3. SHA-256 change detection

When a post has been modified, the pipeline fetches the sanitized content and computes the canonical JSON hash.

This determines whether any element that actually affects the translation was altered.

Administrative tweaks in WordPress shouldn’t necessarily trigger a new call to Gemini.

The key rule is that the hash and sync timestamp must represent the last successfully processed state, not merely the last attempt.

4. Incremental translation

Only posts requiring translation are processed, capped at 10 articles per run.

This limits resource spikes and prevents accidental mass-processing.

5. Build and deployment

Once the content is updated:

hugo --gc --minify

Hugo builds the static site and clears unused cache files.

Then:

rsync -a --delete-after

syncs the output with:

/var/www/juredev-en/en/

Finally, the pipeline purges the matching entry in /var/www/cache so the Spanish version updates its hreflang tags immediately without waiting for cache expiration.

6. SEO: Two Editions, One Coherent Relationship

Hosting two editions of the same article doesn’t mean search engines should view them as duplicate content.

Clearly signaling what each URL represents is essential.

In this architecture, each version carries its own canonical URL:

  • The Spanish post points to its Spanish URL.
  • The English post points to its English URL.

Both editions reference each other via hreflang.

Conceptually, for example:

<link
    rel="alternate"
    hreflang="es"
    href="https://juredev.com/blog/2026/12/mi-articulo/"
/>

<link
    rel="alternate"
    hreflang="en"
    href="https://juredev.com/en/blog/2026/my-article/"
/>

<link
    rel="alternate"
    hreflang="x-default"
    href="https://juredev.com/blog/2026/12/mi-articulo/"
/>

The x-default reference here points to the Spanish version as the default fallback.

This is a valid choice if that is the experience you want to offer visitors without a specific language or regional match. If a language selector page is introduced later, that URL could serve as the default fallback instead.

What matters is that both pages maintain coherent, reciprocal references, and that translations that do not yet exist are never advertised.

Other key elements to maintain in Hugo templates include:

  • <html lang="en"> for language declaration.
  • Canonical tag matching the English URL.
  • Open Graph metadata.
  • Translated title and description.
  • Publication dates.
  • JSON-LD structured data.
  • Including English URLs in the sitemap.

The English edition must be decoupled from a publishing perspective, but not isolated from discovery and indexing.

7. Consistency and Operations: What Happens When Things Fail

A decoupled architecture offers a significant advantage: an issue during English site generation won’t impact the availability of the original Spanish blog.

However, it introduces a trade-off that is important to understand: synchronization is not a distributed transaction.

WordPress and Hugo do not share a transaction guaranteeing simultaneous atomic updates.

There can be a transient window where WordPress has updated content while Hugo is still serving the previous version.

This is an eventual consistency model.

The cron job reconciles state, eventually bringing the English edition up to the latest successfully processed revision.

Different deployment stages must also be handled independently:

If Gemini fails, the retry policy kicks in.

If Hugo fails to build, rsync must not sync the broken build.

And if rsync fails during transfer, you cannot assume the destination directory remains cleanly in the old or new state.

Using rsync --delete-after defers deletions until after files are transferred, but it doesn’t make the deployment atomic. During a sync, a visitor could momentarily hit a mix of files across versions.

For this blog, rsync’s simplicity is sufficient. However, if stricter atomic deployment guarantees are needed later, an evolution would be building each release into a staging folder and swapping a symlink or docroot pointer atomically at the filesystem level.

That would be a future enhancement, not a feature of the current setup.

Furthermore, the pipeline must log enough telemetry for debugging. Dedicated log files allow inspecting failures without mixing Hubs and English edition operations.

In this kind of architecture, you need visibility into the last run, processed posts, errors, and the last successful sync.

Having a cron scheduled isn’t enough: you must know if and when it stopped doing its job.

8. Real-World Quirks That Only Surface in Production Testing

Even with unit tests passing, the first live run across 112 historical articles will always teach you something.

In my case, several concrete and illuminating edge cases emerged.

8.1. PHP’s Classic json_encode([]) Quirk

When translating the first article with an empty URL map, PHP returned:

[]

instead of:

{}

The difference looks minor, but to Python it is significant.

The first value represents a list, while the second is a dictionary/object.

Because the consumer expected a dictionary, it attempted to look up keys on a list, throwing:

list indices must be integers

The fix was forcing the object type in PHP:

json_encode((object) $map);

along with validating the expected type in Python.

A solid reminder that language interoperability contracts must explicitly define types, even for empty collections.

8.2. Latency and Nginx Reloads

During tests executing:

systemctl reload nginx

followed immediately by curl, I noticed a race condition: a request fired right after the reload command could hit worker processes during their phased replacement.

Nginx reloads gracefully without abruptly severing existing connections. Old workers finish handling active requests while new workers spin up to take incoming traffic.

Therefore, reload should not be treated as an instantaneous, atomic process replacement.

Model selection for Gemini also revealed significant differences.

Heavy reasoning models added latency, and during those runs, I observed intermittent 503 errors.

In contrast, gemini-3.8-flash handled technical translations in seconds and proved far more operationally reliable for this pipeline.

Model selection shouldn’t rely solely on maximum reasoning power. Latency, cost, stability, and “good enough” quality for the specific task matter just as much.

Additionally, model identifiers and availability evolve over time. This choice should be seen as what was used during this implementation, not an immutable recommendation.

8.3. Legacy HTML, <T> Generics, and SVG Emojis

Processing older articles revealed three edge cases typical of content written across different phases of the blog:

  1. Legacy code blocks: several posts from early 2025 used <p><code style="...white-space:pre;display:block..."> instead of <pre><code>. Because the code shielding initially only targeted <pre>, markdownify collapsed those blocks onto a single line. Extending the BeautifulSoup detector to protect those blocks prior to Markdown conversion solved it.
  2. Invisible <T> generics in Hugo: expressions like **Box<T>** in plain text led Goldmark (with unsafe = true) to interpret <t> as an unknown HTML tag hidden by the browser. Escaping <...> tokens that do not match valid HTML tags outside code blocks brought generic types back into view.
  3. External SVG emojis tripping the Gatekeeper: in a recent article, a ✅ emoji was rendered as <img src="https://abs-0.twimg.com/emoji/v2/svg/2705.svg" alt="✅">. Gemini simplified it to the Unicode character ✅, which the Gatekeeper flagged as a missing image. Normalizing emoji <img> tags to their alt text before extracting image URLs eliminated the false positive.

9. The Result: An Independent Edition Without Duplicating WordPress

The architecture adheres to the philosophy I established in the previous iteration of my technical Hubs: each component does one thing well.

WordPress is strictly limited to editing and managing original Spanish content.

Python fetches and normalizes content, manages synchronization metadata, and orchestrates processing.

Gemini translates content under a strictly typed contract.

The Gatekeeper protects output integrity before allowing publication.

Hugo generates static HTML.

Finally, Nginx serves the English edition directly from the filesystem, keeping PHP entirely out of /en/ requests.

In my final benchmarks across the complete archive (112 articles and 162 generated pages), Hugo’s build completes in approximately 190 ms. This figure reflects only the static build step in my specific testing environment. It does not represent total synchronization, translation, or deployment time, nor should it be taken as a universal benchmark for any site.

The main advantage isn’t just raw speed.

It is that the English edition has an independent release cycle, avoids duplicating editorial management, and doesn’t inject a bloated translation subsystem into WordPress.

This architecture isn’t meant to argue that multilingual plugins are obsolete. WPML and Polylang remain completely valid and are often far more practical for projects that need manual translation workflows, complex editorial relationships, or multi-language authoring directly inside WordPress.

It simply demonstrates an alternative approach when you want fine-grained control over every step and clear separation of concerns.

And there is an additional thought on using artificial intelligence that I find worth highlighting:

Using AI doesn’t mean offloading your architecture to it.

Gemini handles a specific task: translating content. But version control, code integrity, output validation, synchronization, error handling, and deployment remain the responsibility of the software we design and build.

AI provides a capability that previously required extensive manual effort. Engineering dictates how that capability is integrated, what guardrails surround it, and what happens when an output fails expectations.

That is perhaps the most interesting aspect of this project: I didn’t use artificial intelligence to replace software engineering, but to introduce a new capability inside an architecture that retains full control over the process.

And if everything worked as intended as you finish this sentence, in a few minutes this very article will be compiled and live under /en/blog/.