Blog › Jekyll

Building a bilingual Jekyll Chirpy blog with dual builds

How I added Korean and English editions to a Jekyll Chirpy blog using dual builds, collections_dir, reciprocal hreflang tags, and automated CI checks.

Building a bilingual Jekyll Chirpy blog with dual builds

I added an English edition (/en/) to my Korean Jekyll Chirpy blog without installing a third-party multilingual plugin. This post covers the dual-build architecture, the theme pitfalls I hit along the way, reciprocal hreflang SEO setup, and the automated CI checks that keep both sites in sync.

Tested with Jekyll 4.4, jekyll-theme-chirpy 7.6.0, Ruby 3.4, and GitHub Pages deployed via GitHub Actions.

Why dual builds instead of a multilingual plugin

Most Jekyll multilingual guides start with jekyll-polyglot. It handles URL prefixes and language routing inside a single build, which works well for plain themes. With Chirpy, however, layouts, search.json, PWA service workers, and locale dictionaries are tightly wired together.

Patching Site#process and Jekyll’s collection pipeline with a heavy plugin creates ongoing friction whenever Chirpy updates or when custom hooks enter the mix. Running two independent Jekyll builds—Korean at / and English at /en/—and merging them with rsync keeps the gem-based theme untouched while isolating search indexes, RSS feeds, and sitemaps automatically.

Criterionjekyll-polyglot single build_config_en.yml dual build + rsync merge
Chirpy theme compatibilityHigh risk of breakage on theme upgradesPreserves stock gem-based Chirpy behavior
Search, RSS, and sitemap isolationRequires plugin-specific tweaksSeparate search.json, feed.xml, and sitemap.xml out of the box
Build timeScales inside one processTwo builds (~15–20s total for ~200 posts)
Translation pairingAutomatic via shared slug or page_idExplicit alt_url in Front Matter, verified in CI
Best fit4+ languages with full 1:1 translation2–3 languages mixing translated and standalone posts

Dual builds are not the right choice for every site. Skip this pattern if you maintain four or more languages or translate every page strictly in lockstep. Each extra language adds another config override, another exclude list to keep in sync, and another build pass in CI. For a personal engineering blog that publishes primarily in one language and translates selected articles—or publishes standalone English posts—dual builds stay simple and predictable.

Configuration and directory layout

The setup relies on two built-in Jekyll features: layered --config files and collections_dir. The Korean build reads _posts/ and _tabs/ from the repository root, while the English build reads en/_posts/ and en/_tabs/.

flowchart TD
    A["Shared config (_config.yml + _config_prod.yml)"] --> B["Korean build (baseurl: '')"]
    A --> C["English build (+ _config_en.yml, baseurl: /en)"]
    B --> D["_site/ root output"]
    C --> E["Temp output /tmp/_site_en"]
    E -->|"rsync (skip images, robots, ads)"| F["Merged into _site/en/"]
    D --> F

Here is the core of _config_en.yml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# _config_en.yml
lang: en
locale: en_US
baseurl: /en
collections_dir: en
alternate_language_home: /

title: Namju's Commit Log
tagline: Engineering notes, troubleshooting, and things learned along the way.
description: Notes on backend engineering, infrastructure, and lessons from building software.

author:
  name: Namju Kim
  url: https://namju.kim/en/about/

pwa:
  enabled: false

# Jekyll replaces the entire exclude array across config files.
# Keep shared entries in sync with _config.yml.
exclude:
  - "*.gem"
  - "*.gemspec"
  - docs
  - tools
  - README.md
  - AGENTS.md
  - LICENSE
  - _posts
  - _drafts
  - robots.txt
  - ads.txt

Two details matter here from day one:

  1. Share image assets instead of duplicating them. Every post references local images from the root path (/assets/images/YYYY-MM-DD/name.png). In production, _config_prod.yml rewrites those paths to jsDelivr CDN for both builds, so the English output never needs its own copy of assets/images/.
  2. Prevent PWA Service Worker collisions. If the root Korean Service Worker caches /en/ routes, English updates can serve stale assets or broken fallbacks. I added /en to pwa.cache.deny_paths in _config.yml and set pwa.enabled: false in _config_en.yml so no second Service Worker registers under /en/.

Chirpy integration and real-world pitfalls

The architecture looks straightforward on paper, yet wiring it into Chirpy exposed three concrete Jekyll and Liquid edge cases.

1. Missing _tabs collection in the English build

My first version of _config_en.yml listed _tabs under exclude to stop the English build from reading the root Korean tabs. After building, /en/about/, /en/archives/, /en/categories/, and /en/tags/ vanished completely.

The cause sits inside Jekyll’s CollectionReader and EntryFilter. Even when collections_dir: en is set, Jekyll matches collection documents against exclude using their collection-relative path (_tabs/about.md) rather than en/_tabs/about.md. Listing _tabs in _config_en.yml filtered out en/_tabs/ too. Removing _tabs from the English exclude list fixed all four tab pages immediately.

2. Liquid 4 incompatibility in the language switcher

I placed a globe icon in the sidebar footer so readers can jump directly between paired translations. My initial _includes/language-switcher.html used the multi-line {% liquid ... %} tag, which failed to evaluate in Jekyll 4.4 because it bundles Liquid 4 (the liquid tag arrived in Liquid 5). Switching back to standard {%- if ... -%} tags resolved it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- _includes/language-switcher.html -->
{%- capture alternate_path -%}{% include alternate-language-url.html %}{%- endcapture -%}
{%- if site.lang == 'en' -%}
  {%- assign alternate_lang = 'ko' -%}
  {%- assign switch_label = 'Korean' -%}
  {%- assign home_suffix = ' home' -%}
{%- else -%}
  {%- assign alternate_lang = 'en' -%}
  {%- assign switch_label = '영어' -%}
  {%- assign home_suffix = ' 홈' -%}
{%- endif -%}
{%- if alternate_path == empty -%}
  {%- assign switch_label = switch_label | append: home_suffix -%}
{%- endif -%}
<a
  id="language-switcher"
  href="{{ alternate_path | default: site.alternate_language_home | escape }}"
  hreflang="{{ alternate_lang }}"
  aria-label="{{ switch_label | escape }}"
  title="{{ switch_label | escape }}"
>
  <i class="{{ include.icon | escape }}" aria-hidden="true"></i>
</a>

When a post has a paired translation, the globe links directly to alt_url. On untranslated posts, it falls back cleanly to site.alternate_language_home (/ or /en/).

3. Updating custom Ruby hooks for collections_dir

Custom plugins under _plugins/ also need to respect collections_dir. My _plugins/posts-lastmod-hook.rb runs a single git log per build to populate last_modified_at, and it originally queried _posts directly. Because post.relative_path stays _posts/... during the English build, I prepended collections_dir when present so the lookup matches Git’s actual tracked path (en/_posts/...):

1
2
3
4
5
6
7
8
9
10
# _plugins/posts-lastmod-hook.rb (excerpt)
collections_dir = site.config['collections_dir']
posts_dir = collections_dir.empty? ? '_posts' : File.join(collections_dir, '_posts')

site.posts.docs.each do |post|
  rel_path = collections_dir.empty? ? post.relative_path : File.join(collections_dir, post.relative_path)
  if commit_counts[rel_path] > 1 && latest_dates[rel_path]
    post.data['last_modified_at'] = latest_dates[rel_path]
  end
end

By contrast, my folder-based category hook (_plugins/category-folder-hook.rb) needed zero changes because post.relative_path keeps the _posts/{Category}/{Subcategory}/... shape in both builds. I also added _plugins/english-empty-pages-hook.rb so /en/ index pages render a clear empty-state message before the first English posts existed.

Reciprocal hreflang and multilingual SEO

Search engines treat paired translations as localized versions—not duplicate content—only when both pages emit reciprocal hreflang links pointing to each other.

Instead of copying and overriding Chirpy’s entire _includes/head.html, I used Chirpy’s official _includes/metadata-hook.html extension point. First, a small helper partial resolves the alternate path:

1
2
3
4
5
6
7
8
9
<!-- _includes/alternate-language-url.html -->
{%- if page.alt_url -%}
  {{- page.alt_url -}}
{%- elsif page.layout == 'home' -%}
  {%- assign home_path = page.url | strip_index -%}
  {%- if home_path == '/' -%}
    {{- site.alternate_language_home -}}
  {%- endif -%}
{%- endif -%}

Then _includes/metadata-hook.html emits ko, en, and x-default tags whenever an alternate path exists:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!-- _includes/metadata-hook.html (multilingual SEO excerpt) -->
{%- capture alternate_path -%}{% include alternate-language-url.html %}{%- endcapture -%}
{% if alternate_path != empty %}
  {% assign current_url = page.url | absolute_url | strip_index %}
  {% assign alternate_url = site.url | append: alternate_path %}
  {% if site.lang == 'en' %}
    {% assign english_url = current_url %}
    {% assign korean_url = alternate_url %}
  {% else %}
    {% assign english_url = alternate_url %}
    {% assign korean_url = current_url %}
  {% endif %}
  <link rel="alternate" hreflang="ko" href="{{ korean_url | escape }}">
  <link rel="alternate" hreflang="en" href="{{ english_url | escape }}">
  <link rel="alternate" hreflang="x-default" href="{{ korean_url | escape }}">
{% endif %}

Both files in a translation pair declare domain-root alt_url values in Front Matter. You can test it right now on this page: the globe button in the sidebar switches to the Korean edition via alt_url: /posts/jekyll-chirpy-multilingual-dual-build/.

Finally, the root robots.txt advertises both generated sitemaps so crawlers discover both language trees independently:

1
2
3
4
5
6
# robots.txt
User-agent: *
Disallow: /norobots/

Sitemap: https://namju.kim/sitemap.xml
Sitemap: https://namju.kim/en/sitemap.xml

GitHub Actions assembly and automated checks

In .github/workflows/pages-deploy.yml, the workflow builds the Korean site into _site, builds the English site into a temporary directory, merges it into _site/en/ with rsync, and runs two verification passes before deploying:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# .github/workflows/pages-deploy.yml (build & check excerpt)
- name: Build site
  run: |
    mkdir -p _cache
    echo "cdn: 'https://cdn.jsdelivr.net/gh/${{ github.repository }}@${{ github.sha }}'" > _config_ci.yml
    en_dest=$(mktemp -d "$RUNNER_TEMP/jekyll-en.XXXXXX")
    bundle exec jekyll build -d "$PAGES_DEST" --config _config.yml,_config_prod.yml,_config_ci.yml
    bundle exec jekyll build -d "$en_dest" --config _config.yml,_config_prod.yml,_config_ci.yml,_config_en.yml
    rsync -a --exclude='/assets/images/' --exclude='/robots.txt' --exclude='/ads.txt' "$en_dest/" "$PAGES_DEST/en/"
  env:
    JEKYLL_ENV: "production"
    PAGES_DEST: "_site${{ steps.pages.outputs.base_path }}"

- name: Test site
  run: |
    bundle exec htmlproofer _site \
      --disable-external \
      --ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/"

- name: Verify multilingual output
  run: python3 tools/check-multilingual.py "$PAGES_DEST"
  env:
    PAGES_DEST: "_site${{ steps.pages.outputs.base_path }}"

Excluding /assets/images/, /robots.txt, and /ads.txt during rsync avoids doubling the Pages artifact size and keeps root-only files out of /en/.

The most common failure mode in manual alt_url pairing is a one-sided link or typo that silently breaks hreflang. To catch regressions before deployment, I wrote a dependency-free Python validator (tools/check-multilingual.py) that parses every generated HTML file and enforces six invariants:

  1. Every page sets the right <html lang> (ko or en), and English pages declare og:locale as en_US.
  2. Every page with hreflang outputs the exact {ko, en, x-default} triad, its target page exists, and both pages emit identical reciprocal hreflang sets.
  3. canonical matches the page’s own URL, and noindex pages never appear in hreflang or sitemap.xml.
  4. The sidebar #language-switcher link points to a valid page in the built artifact.
  5. Every entry in /en/assets/js/data/search.json starts with /en/posts/ and resolves to an existing HTML file.
  6. The root swconf.js excludes /en from Service Worker caching, and English pages do not load /en/app.min.js.

You can run the exact same assembly and validation locally before pushing:

1
2
3
4
5
rm -rf /tmp/_site /tmp/_site_en
JEKYLL_ENV=production bundle exec jekyll build -d /tmp/_site --config _config.yml,_config_prod.yml
JEKYLL_ENV=production bundle exec jekyll build -d /tmp/_site_en --config _config.yml,_config_prod.yml,_config_en.yml
rsync -a --exclude='/assets/images/' --exclude='/robots.txt' --exclude='/ads.txt' /tmp/_site_en/ /tmp/_site/en/
python3 tools/check-multilingual.py /tmp/_site

Production caveats and checklist

Warning: Whenever you add a new entry to exclude in _config.yml, update _config_en.yml at the same time. Jekyll replaces the entire exclude array instead of merging it, so a forgotten entry can leak internal docs or scripts into /en/.

Before shipping a dual-build multilingual setup on Jekyll Chirpy, run through these five checks:

  • Set collections_dir: en and baseurl: /en in _config_en.yml, and leave _tabs and en out of the English exclude list.
  • Add /en to pwa.cache.deny_paths in _config.yml and disable pwa.enabled in _config_en.yml to prevent Service Worker interference.
  • Audit custom _plugins/*.rb hooks so Git or filesystem lookups prepend site.config['collections_dir'] when non-empty.
  • Declare reciprocal domain-root alt_url paths on paired posts and list both sitemaps in root robots.txt.
  • Run both htmlproofer and a dedicated multilingual HTML validator in CI so broken hreflang pairs fail the build.

References

The tables below list the available settings for Jekyll, and the various options (specified in the configuration file) and flags (specified on the command-line) that control them.
Learn how you can use a sitemap and other methods to tell Google about all of the different language and regional versions of your pages.
This post is licensed under CC BY 4.0 by the author.