# How do I set up SEO for a multilingual Next.js app?

52.2 s · Narrator: Frederick Surrey

Give every language its own URL, set the html lang attribute, point each page's canonical URL at itself, add hreflang alternates for every language, translate titles and descriptions, and list every language version in your sitemap.

| Time | Voice | Line | On screen |
| --- | --- | --- | --- |
| 0:00.88 | Narrator | In Madrid, the search result for your About page shows the English title and URL. | A browser draws in the middle of the frame on a search page: a search field with a magnifying glass, with the tab and the address drawn as bars. On "Madrid" the language code `es` appears over its top right corner, and on "the" three results rise. The first reads "example.com/about" over "About Us"; the other two are drawn as bars. The heading "An English title and URL" rises on "your". On "English" the title "About Us" turns blue, and on "URL" the blue moves to "example.com/about". |
| 0:06.10 | Narrator | Your app shows Spanish with gt-next, but that version has no URL or title of its own. | On "app" the browser cuts to the About page: the tab reads "About Us", the address reads "example.com/about", the page's copy is drawn as bars, and a language menu in its top right is set to Spanish. On "Spanish" a white box draws around the language menu; it moves to the address on "version" and to the tab on "title". |
| 0:12.58 | Narrator | General Translation lets you give every language its own URL and tell search engines about them. | The answer card cuts in on "General": the answer alone rises as it is spoken, in two lines, "General Translation lets you give every language" then "its own URL and tell search engines about them", and the General Translation mark sits small in the lower left corner. |
| 0:19.30 | Narrator | Move your pages into app/[locale], and the middleware serves Spanish at /es/about. | A code panel opens with the project's files, `./`: `app/` with `layout.tsx`, `page.tsx` and `about/page.tsx`, then `gt.config.json`, `next.config.ts` and `package.json`. On "pages" a white box draws around `app/` and its four rows, and on "into" the browser draws again on the right, on the About page, with three rows under it: `lang`, which reads `es`, then `canonical` and `hreflang`, still empty. On "app/[locale]" `app/` becomes `app/[locale]/`. On "the" the heading "Spanish at /es/about" rises and the code panel cuts to `proxy.ts`, and on "middleware" `createNextMiddleware` turns blue. On "serves" a line runs from `export default createNextMiddleware();` along the top to the address bar, and the address becomes "example.com/es/about"; on "/es/about" a white box draws around it. |
| 0:26.78 | Narrator | The root layout sets the html lang attribute with useLocale. | The heading "Set the html lang attribute", and the code panel cuts to `app/[locale]/layout.tsx`. On "html" `lang={locale}` turns blue, and on "attribute" a line joins `<html lang={locale}>` to the browser's `lang` row. On "useLocale" the blue moves to `useLocale` in the import and the call, the line goes, and a white box draws around the row's value, `es`. |
| 0:31.82 | Narrator | A helper adds canonical and hreflang links, and getGT translates the title. | The code panel cuts to `app/[locale]/about/page.tsx`, whose `generateMetadata` returns `await getI18NMetadata('/about')`. On "helper" the helper call turns blue. On "canonical" the heading "Canonical and hreflang links" rises, and a line joins the helper call to the browser's `canonical` row, which fills with "https://example.com/es/about". On "links" the `hreflang` row fills with `en  es  ja  fr  x-default`, and on "and" the line goes. On "getGT" `import { getGT } from 'gt-next/server';` and `const t = await getGT();` open, on "translates" the return becomes an object with `title: t('About Us'),`, and on "the" the helper's result is spread into it. On "title" a line runs along the top to the tab, which changes to the Spanish title. A blue bar marks each changed line. |
| 0:38.82 | Narrator | A sitemap lists every page in every language. | The heading "A sitemap for every language", and the code panel cuts to `app/sitemap.ts`. On "sitemap" the browser drops away. On "lists" a `sitemap.xml` panel opens on the right with `https://example.com` and its `/es`, `/ja` and `/fr` versions. On "page" `PAGES.flatMap` turns blue, and on the second "every" a line joins `url: getUrl(locale),` to those four rows. On "language" the blue moves to `LOCALES.map`, and `https://example.com/about` and its `/es`, `/ja` and `/fr` versions rise under them. |
| 0:42.48 | Narrator | In Madrid, the result can now show the Spanish title and URL. | The browser cuts back in the middle of the frame on the search page, with the code `es`. On "Madrid" the three results rise, and the first now reads "example.com/es/about" over the Spanish title. On "Spanish" the title turns blue, in the place where "About Us" turned blue at the start, and on "URL" the blue moves to "example.com/es/about". |
| 0:47.02 | No voice |  | The end card: the General Translation logo with generaltranslation.com/docs/react/nextjs/app-router-middleware under it, held to the last frame while the music ends on a held chord. |

Times are where each line starts in the final, read from the film's own audio.
