Skip to content
Technical SEO

Technical SEO for a Next.js site, done once and correctly

Canonicals, hreflang, sitemaps, robots and metadata on the App Router — including the three that are almost always wrong on a bilingual site.

What does technical SEO require on a Next.js App Router site?

Mostafa Nouh — portraitMostafa NouhPublished 8 min read

Metadata comes from data, never from strings

The App Router's generateMetadata runs on the server with the same params the page uses, so the title, description and canonical can be derived from the record the page is about. A hand-written title in a page file is a second copy of a fact, and second copies drift.

One canonical per language

The Arabic page and the English page are not duplicates of each other — they are alternates. Each one canonicalises to itself. Pointing the Arabic page's canonical at the English URL, which happens constantly, tells a search engine that the Arabic version should not be indexed at all.

hreflang has to be reciprocal

  • Every page lists every language version of itself, including its own.
  • The declarations must agree in both directions — if A names B, B must name A.
  • Use absolute URLs. A relative alternate is ignored.
  • Include an x-default pointing at the version a visitor with no language match should get.
  • Never generate alternates for a page that does not exist in that language.

The sitemap is generated, not maintained

Build it from the same arrays that produce the routes, so a new case study appears in the sitemap the moment it exists and an unpublished draft never does. Include lastModified from the record's own date rather than the build time — a sitemap where every URL changed today says nothing.

robots.txt, and what you are deciding

Disallowing a path does not remove it from an index — it prevents crawling, which can leave a URL indexed with no description. Use noindex for pages that should not appear, and robots.txt for paths that should not be fetched. They are different tools and using one for the other's job is the most common technical SEO mistake there is.

Before a Next.js site ships

  • View source on three routes: is the content in the HTML, or only after hydration?
  • One self-referencing canonical per page, absolute, matching the served URL exactly.
  • Reciprocal hreflang across both languages, plus x-default.
  • One JSON-LD @graph per page with stable @id values shared across the site.
  • sitemap.xml generated from route data, with honest lastModified values.
  • robots.txt allows the crawlers you intend — check the AI user agents explicitly.
  • A 404 that returns 404, and a redirect map for every URL that ever changed.
  • OpenGraph images that exist and resolve absolutely.

Sources

Contact

Have a site or store that needs to work better?

Tell me what is happening and on which page. A diagnosis is a useful first deliverable on its own.

I read every message myself and reply within one working day — usually with a question or two before anything else, because a scope worth quoting needs them answered.

Available for remote work aligned to EST hours
Mostafa Nouh — portrait

Mostafa Nouh

Full-Stack Developer & Product Builder

Location
Egypt · Remote