# Languages

> One blog per language, from language directories under blog/.

Name the directories directly under `blog/` after language codes and JAAB
builds one blog per language, with a switcher in the header. It is the rule of
[JAAD's languages](https://docs.jaamd.org/jaad/guides/languages.md), applied to posts.
With the blog at `routeBase: '/blog'`, as on this page:

```
blog/
  en/
    index.md                    → /blog/
    2026-11-22-hello.md         → /blog/hello/
  it/
    index.md                    → /blog/it/
    2026-11-22-hello.md         → /blog/it/hello/
```

Nothing needs configuring. Without language directories, or with a lone one
that `lang` does not name, nothing changes: see below.

## Detection

A directory is a language when its name is an ISO 639-1 code, optionally with a
script and a region: `it`, `pt-BR`, `zh-Hans`.

**Two directories make the blog localised.** A single one counts only when
[`lang`](https://docs.jaamd.org/jaad/configuration/lang.md) names it: `blog/en/`
with `lang: "en"` is a first language about to be translated, while a lone
`blog/it/` on an English blog stays a
[folder of posts](https://docs.jaamd.org/jaab/getting-started/posts.md), served at `/blog/it/…`.

Once the blog is localised, every entry under `blog/` has to be a language
directory, `index.md` included: each language has its own. Hidden entries, such
as `.DS_Store`, do not count. A stray one stops the build and is named:

```
jaab: mixed blog tree
  blog/index.md is not a locale, but en, it are
Move every post, and the index.md of the blog, under a language directory, or set locales: false.
```

When detection guesses wrong, as with directories of posts named `it/` and
`id/`, set [`locales`](https://docs.jaamd.org/jaab/configuration/locales.md).

## URLs

`lang` names the language that keeps the unprefixed URLs. The others are below
their code, after [`routeBase`](https://docs.jaamd.org/jaab/configuration/routebase.md):

| English         | Italian            |
| --------------- | ------------------ |
| `/blog/`        | `/blog/it/`        |
| `/blog/page/2/` | `/blog/it/page/2/` |
| `/blog/hello/`  | `/blog/it/hello/`  |
| `/blog/rss.xml` | `/blog/it/rss.xml` |

An alias is below its post's language: `aliases: [old]` on an Italian post
redirects `/blog/it/old/`. A post in the default language cannot take another
language's code as its URL.

## Pairing translations

Two posts are translations of each other when their slugs match:
`en/2026-11-22-hello.md` and `it/2026-11-22-hello.md` are both `hello`, and the
date in front does not count.

To translate the URL too, give both files the same `translationKey`:

```markdown
---
title: Installazione
date: 2026-11-22
translationKey: setup
---
```

```
blog/en/2026-11-22-setup.md          → /blog/setup/
blog/it/2026-11-22-installazione.md  → /blog/it/installazione/
```

Two posts of one language pairing the same way stop the build.

## One blog per language

Each language has exactly the posts in its own directory. There is no fallback:
a post that exists only in English is not listed on the Italian index, is not in
the Italian feed or `llms.txt`, and is not built under `/blog/it/`.

Each language has its own index and pages, its own `rss.xml`, and its own
`llms.txt` and `llms-full.txt`. The default language's `llms.txt` links the
others'.

## The switcher

On a post with a translation, the switcher leads to it. On a post with none in a
language, it leads to that language's index rather than to a URL that would
404; on an index, to the other languages' indexes.

## The page

Each page is in its language: `<html lang>`, the dates, the interface and the
feed the header links. Its `<head>` carries `og:locale`, `og:locale:alternate`,
and a `hreflang` link for each real translation, with `x-default` on the default
language's page. `hreflang` links need [`site`](https://docs.jaamd.org/jaad/configuration/site.md).

To change the interface's strings in a language, see
[`ui`](https://docs.jaamd.org/jaad/configuration/ui.md).

## Beside JAAD

The docs and the blog have languages of their own: docs in English alone keep
their pages beside a blog in English and Italian, and neither gets the other's
switcher entries.

## Writing a post

`jaab new` does not read the config. When `blog/` holds only language
directories, it needs the post's language, and stops without one:

```bash
npx jaab new "Ciao" --lang it
```
