seo-metadata-and-sitemap

SEO Metadata, Sitemap & Canonical Links

The YouTeacher landing page is a Next.js app rendered per locale, and this subsystem is how it makes itself discoverable to search engines. Everything is driven off one small list of locales — en and zh, with en as the default — so title text, canonical URLs, sitemap entries, and language alternates all stay in sync with a single source of truth.

Per-locale metadata

The locale layout exports a generateMetadata function that runs once per locale. It reads the page title and description from the translation catalog's metadata namespace, so the text a search engine sees is localized rather than hard-coded. From the same two strings it also builds an OpenGraph block — title, description, type: website, and an OpenGraph locale that maps zh to zh_CN and everything else to en_US. So a link shared into a chat or social preview carries the right language and framing.

Canonical and hreflang alternates

The metadata also declares alternates: a canonical URL of /<locale> for the current page, plus a languages map pointing en/en and zh/zh. This is the hreflang signal — it tells a crawler that the English and Chinese pages are translations of one another, not duplicate content, and names which URL is authoritative for each language.

Static params and the locale guard

generateStaticParams enumerates the locale list so Next.js can prerender each locale's route at build time. The layout itself validates the incoming locale and returns a 404 (notFound) for anything not on the list, sets the request locale, loads the messages, and wraps the page in the app's providers. So an unknown language segment never renders a broken half-localized page.

Sitemap and robots

Two route files complete the picture, both rooted at https://youteacher.io:

  • sitemap.ts generates one entry per locale (/en, /zh), each marked changeFrequency: weekly and priority: 1, with lastModified set at generation time. The sitemap grows automatically if a locale is added.
  • robots.ts allows all crawlers (userAgent: *, allow: /) and points them at https://youteacher.io/sitemap.xml.

The through-line: the locale list is the single input, and metadata, canonicals, alternates, and the sitemap are all derived from it rather than maintained by hand.

about this entry

One of sijie's wiki entries. The AI on this site is grounded in the same corpus and answers in sijie's voice, with citations back to entries like this one — answering costs sijie money, so it waits behind a code: enter an access code →