Arabic SEO with Next.js
Learn to build Arabic Next.js URLs, localized metadata, canonical links, hreflang sets and sitemaps, then verify their deployed output.
By Omran Khleifat, Founder of Ritla
Guide14 min read
An Arabic workshop page can have a translated heading while its canonical identifies the English version, its search title describes a different workshop, and its sitemap lists a translation that has never been published. Each output may look reasonable in isolation. Together, they describe a site that does not exist.
Arabic SEO with Next.js starts by making those outputs agree about which page is being served. The route, visible content, title, canonical, language alternates and sitemap entry should come from the same published content variant. Adding an Arabic prefix to a URL is not enough.
Metadata is part of that work, but it is not the whole explanation for an absent search result. An English description does not itself make a page unindexable, and correct tags do not guarantee indexing. This guide separates crawl access, page identity, language relationships and search appearance, using a fictional ceramics studio in Jordan as the running example.
The code targets the Next.js App Router with awaited route parameters. Pages Router applications need their own document and head integration, but the URL relationships and verification steps remain applicable.
Diagnose the response before rewriting metadata#
Open the exact public Arabic URL without a signed-in session. Record the final URL, redirect chain, response status, indexing directives and main content. Do this on the deployed application, not only in development.
Use the result to decide which problem you are solving:
| Observation | Investigate first |
|---|---|
| Arabic URL redirects to English | Locale negotiation, route matching and redirect rules |
| Response is a login screen or unavailable page | Public access and publication state |
Page carries noindex | Page metadata, response headers and deployment policy |
| Workshop is Arabic but canonical is English | Canonical construction and inherited defaults |
| Only navigation is Arabic | Translation selection for the main content |
| Live page is correct but indexed information is old | Last crawl and indexed-page evidence |
These are diagnostic starting points. A successful HTTP response alone does not prove that the intended workshop was served. Inspect a distinctive heading and a paragraph of course information as well.
Check both a robots meta tag and the X-Robots-Tag response header. A hosting rule can add an indexing restriction outside your React code. Also distinguish blocking crawling from preventing indexing: Google must be allowed to fetch a page to discover its noindex directive. Its indexing-control documentation explains why a robots.txt block is not a substitute.
Keep preview and production policy separate. A preview may deliberately be private or non-indexable. Test metadata there, but do not expect it to behave like a publicly indexable production page. After promotion, verify that preview-only headers and access restrictions have not followed the build into production.
Give the Arabic version a stable public URL#
A language switch that changes a cookie while leaving the same URL does not provide a dependable address for each translation. Google recommends separate URLs for language versions. Its crawler also does not send an Accept-Language header, so language negotiation cannot be the only way to expose Arabic content.
For the studio, each published workshop has an English and an Arabic address. A visitor opening the Arabic deep link should receive that version even with English browser preferences. A remembered preference can help at a neutral entry point, but should not make an explicit Arabic URL inaccessible.
Use a real hyperlink for the language switcher, pointing to the equivalent workshop. A click handler that merely changes client state is harder to inspect and does not give the visitor a stable destination to copy or open separately.
The pathname may contain Arabic words or an untranslated slug. Choose a policy the team can maintain, then store the actual paths. Do not rename established URLs merely to make their slugs look more localized. If a published slug changes, plan the old URL's redirect and update internal links, alternate relationships and sitemap entries together.
Test direct requests as well as navigation. A route can work after the app has loaded and fail when someone opens the same link from a search result. Refresh the Arabic workshop detail page, open it in a fresh context and follow its language link in both directions.
Treat publication as a property of the translation, not just the workshop. An English workshop may be ready while its Arabic version is still being edited. Do not manufacture an Arabic URL for it and silently serve the English description under that address.
Pair translations by content identity, not path replacement#
The English and Arabic pages need to identify the same workshop, even when their slugs differ. Replacing /en/ with /ar/ cannot establish that relationship.
Keep a stable content identity with the published variants attached. This small fixture represents one workshop and supplies the examples below:
// lib/workshop.tsexport const publicOrigin = 'https://claystudio.example';export const publicURL = (path: string) => new URL(path, publicOrigin).href; export const variants = [ { lang: 'ar', hreflang: 'ar-JO', ogLocale: 'ar_JO', path: '/ar/workshops/تشكيل-الأكواب', title: 'ورشة تشكيل الأكواب بالطين في عمّان', description: 'تعلّم تشكيل كوب من الطين يدوياً في ورشة عملية للمبتدئين في عمّان.', updatedAt: '2026-10-19', }, { lang: 'en', hreflang: 'en-JO', ogLocale: 'en_JO', path: '/en/workshops/handbuilt-cups', title: 'Handbuilt clay cup workshop in Amman', description: 'Learn to shape a clay cup by hand in a practical beginner workshop in Amman.', updatedAt: '2026-10-21', },] as const;The origin is fictional. Replace it with the intended public origin. The fixture contains published variants only; a CMS-backed implementation should filter drafts before generating public relationships.
The route segment, language tag and Open Graph locale have separate fields deliberately. They serve different interfaces. The URL prefix is a routing choice, not a universal locale identifier.
Use this record to resolve the visible workshop, construct the language switcher and generate metadata. At catalog scale, look up the content identity from the requested locale and slug, then obtain its published variants. Never find an unrelated workshop just because its English slug happens to match.
Make the missing-translation behavior explicit. Returning a localized unavailable view, omitting the destination from the switcher, or offering a clearly labeled link to the English version are product choices. Claiming that the English page is an Arabic translation is a data error.
Generate metadata from the resolved page variant#
A static English export copied into a shared locale route gives every version the same search description:
// Problem: applied to both language versions of this workshopexport const metadata = { title: 'Handbuilt clay cup workshop in Amman', description: 'Learn to shape a clay cup by hand in a practical beginner workshop in Amman.',};Use the validated route parameters to select the same variant as the page body. This is the metadata portion of app/[lang]/workshops/[slug]/page.tsx; keep the page's rendering export alongside it. The examples assume the @/ import alias points to the project root.
import type { Metadata } from 'next';import { notFound } from 'next/navigation';import { variants, publicURL } from '@/lib/workshop'; export async function generateMetadata({ params }: { params: Promise<{ lang: string; slug: string }>;}): Promise<Metadata> { const { lang, slug } = await params; const path = `/${lang}/workshops/${slug}`; const current = variants.find((variant) => variant.path === path); if (!current) notFound(); return { title: current.title, description: current.description, alternates: { canonical: publicURL(current.path), languages: Object.fromEntries(variants.map((variant) => [ variant.hreflang, publicURL(variant.path), ])), }, };}The fixture makes the relationship visible without hiding it behind a CMS helper. In a real application, share a resolver between the rendering function and generateMetadata, including publication checks. Missing content should follow the application's missing-page behavior; Next.js provides notFound() for that boundary.
The Metadata API supports both static exports and route-dependent generation in Server Components. Choose a static export when the file represents one fixed page; use generation when its result depends on route data. Do not export both mechanisms from the same segment.
Inspect the final title, not just the returned string. A parent title template can append site wording, and a shared English default can survive on a page that never supplies its own localized value. Write page-specific Arabic titles and descriptions that accurately describe the workshop. Adding the Arabic word for “workshop” to an otherwise English sentence is not a localized description.
covers a title or meta description that is majority-Latin on an Arabic page. It does not determine whether a title describes the right workshop or promises something the course does not provide; review those details against the content record.
Google can construct its title link from several page signals, and its snippet may come from visible content instead of the meta description. Matching the Arabic heading, description and body is more useful than repeatedly changing a tag to force a particular search-result sentence. There is no fixed character count that guarantees the displayed result will remain untruncated.
Keep canonicals and translation links in different roles#
A canonical identifies the preferred URL for duplicate or substantially similar content. A language alternate identifies another language or regional version. They are not interchangeable.
For this genuinely translated workshop, the Arabic page should identify its own preferred Arabic URL, while the English page identifies its own preferred English URL. This export on the Arabic page sends the wrong signal:
export const metadata = { alternates: { canonical: 'https://claystudio.example/en/workshops/handbuilt-cups', },};The earlier generator instead selects publicURL(current.path). Its canonical changes with the resolved variant, while the alternate set connects the translations.
Google treats a canonical as a signal, not an instruction it must obey. Its canonicalization guidance recommends a canonical in the same language when using language alternates. Keep internal links and sitemap entries consistent with the preferred URLs too.
Test exact destinations. Checking only that the canonical contains /ar/ misses a different workshop, an old host or the Arabic catalog homepage. Open the canonical target and confirm that it serves the intended content without another normalization redirect.
If you use metadataBase, treat it as URL-resolution configuration, not a locale resolver. It cannot discover a workshop's Arabic counterpart. A shared alternates.canonical that names the homepage also needs a page-specific replacement; it does not become the current workshop URL automatically. The examples use absolute URLs to make both the intended host and destination explicit. Verify trailing-slash normalization against the deployed routing policy.
For tracking parameters, the preferred URL may omit the parameter while retaining the workshop path and Arabic locale. For filters that change the actual page content, decide the indexing policy instead of stripping every query parameter indiscriminately. A catalog filter and a campaign tag are different inputs.
Self-canonicalization is not an absolute rule for every regional duplicate. Two near-identical Arabic pages targeting separate markets need a deliberate canonical and regional strategy. Likewise, an untranslated English body under an Arabic shell is not the translated workshop illustrated here. Fix that content model before copying a self-canonical pattern.
covers a canonical URL pointing at a different-locale variant. It should prompt investigation of the relationship, not a blind replacement of every canonical with the current browser URL, which might contain tracking parameters or a preview host.
Build a reciprocal hreflang set from published equivalents#
For the workshop fixture, both pages should expose the same mapping of ar-JO and en-JO to their respective public URLs, including themselves. Google requires fully qualified alternate URLs and return links between the participating pages. Its localized-version guidelines also explain x-default and supported language-region codes.
The generator above constructs the mapping from the workshop's published variants. That avoids maintaining one set in the Arabic file and another in the English file, where one can be forgotten after a slug change.
Use regional tags because the studio is describing Jordan-specific workshops. If an Arabic page serves Arabic readers without a country-specific target, ar may be the appropriate tag instead. Do not generate a separate URL for every Arabic-speaking country merely to populate a large alternate set.
Add x-default only when you have chosen a real fallback destination for unmatched languages. It can identify a selector or an appropriate default version. It is not a required synonym for English, and an arbitrary homepage should not be presented as the equivalent of every workshop.
Test the relationship as a round trip. Read the Arabic page's English alternate, request that destination, and check that its alternate mapping returns to the original Arabic workshop. Also verify that the destination is published and actually describes the same course. A well-formed tag pointing to a missing page is still defective.
If one translation is removed, update the surviving variant's mapping and the sitemap. If a URL is renamed, update the direct target rather than depending on a chain of redirects to preserve the relationship. Those changes belong to the content-publication workflow.
covers an alternate set lacking any Arabic entry on an Arabic page. A set can contain Arabic and still name the wrong workshop, omit the return relationship or link to an unpublished translation. Keep those assertions in the release tests.
HTML annotations and localized sitemap annotations are alternative ways to communicate these relationships. You do not earn an additional search benefit by maintaining multiple independent versions of the same mapping. If you emit both, derive both from the same data and check that they agree.
Separate document language from Open Graph locale#
The Arabic document should declare its language and direction at the root. For this Jordan-specific version, the relevant opening tag is:
<html lang="ar-JO" dir="rtl">The W3C documents language declarations and document direction separately. lang does not set direction. In a localized App Router tree, produce these attributes in the root layout that owns the document, not by adding a second html inside a nested page.
Correct markup supports language-aware processing and the reading experience. It is not a way to label an English body as Arabic for Google: Google says it identifies page language from visible content, rather than relying on the lang attribute.
Open Graph uses a different notation. Its protocol specifies language_TERRITORY, so the fixture pairs ar-JO for the language alternate with ar_JO for sharing metadata. Open Graph's alternate locales are locale names, not URL mappings, and do not replace hreflang.
Extend the earlier metadata function with these fields inside its returned object:
// current, variants and publicURL are defined in the generator aboveopenGraph: { type: 'website', title: current.title, description: current.description, url: publicURL(current.path), locale: current.ogLocale, alternateLocale: variants .filter((variant) => variant.lang !== current.lang) .map((variant) => variant.ogLocale),},twitter: { title: current.title, description: current.description,},This fragment covers localized text, identity and locale. Add an appropriate public sharing image as part of the complete sharing-card configuration, and inspect any text embedded in that image. Translating the tags cannot translate an English image caption baked into the artwork.
Next.js shallowly merges metadata objects across route segments. Defining a page-level openGraph object can replace nested values inherited from its layout. Inspect the resolved image, title and locale rather than assuming the parent's image survives. covers untranslated OpenGraph/Twitter metadata or missing/invalid og:locale. Sharing previews require their own verification and should not be treated as proof of Google indexing.
Generate the sitemap from the same publication data#
A sitemap should list the URLs you intend search engines to discover and consider for search, not every path your router can construct. For the workshop, include a separate entry for each published translation.
Next.js provides the app/sitemap.ts convention, including language alternates:
// app/sitemap.tsimport type { MetadataRoute } from 'next';import { variants, publicURL } from '@/lib/workshop'; export default function sitemap(): MetadataRoute.Sitemap { const languages = Object.fromEntries(variants.map((variant) => [ variant.hreflang, publicURL(variant.path), ])); return variants.map((variant) => ({ url: publicURL(variant.path), lastModified: variant.updatedAt, alternates: { languages }, }));}This lists the single workshop fixture. For a catalog, repeat the operation per workshop, using each record's own published variant set. Do not attach the complete site's language URLs to every course.
Fetch /sitemap.xml and parse the resulting XML. Check that both workshop URLs are present as entries, not merely as alternate links beneath one entry. If you emit alternates, compare each entry's set with the page metadata. Test an Arabic-only workshop too, so the generator cannot assume every record has an English partner.
Use the translation's meaningful modification date. Arabic publication and English editing may happen on different days. Setting every lastModified to the current request time invents updates that did not happen. Google documents accurate modification dates and absolute sitemap URLs; it also states that it ignores sitemap priority and change-frequency values.
Exercise publication changes against the deployed sitemap. Add an Arabic translation, publish it, and verify that its URL and relationships appear. Unpublish it and check that they disappear according to the intended cache lifecycle. The framework's sitemap handler can be cached, so changing the CMS record alone is not sufficient evidence that the served XML changed.
Use the same public origin policy as the page canonical. A preview can emit production URLs intentionally; production must not emit the preview hostname. Avoid generating public identities from whichever request host happens to reach the server.
Inspect complete responses when metadata streams#
A dynamically rendered Next.js page can send visible content before its generated metadata resolves. Prerendered pages resolve metadata at build time. Next.js also changes delivery for crawlers that need metadata in the document head, as its metadata streaming guide explains.
This matters when debugging a report that the Arabic title or canonical is absent. Reading the opening chunk of a response is not the same as consuming the entire document. Conversely, seeing the correct title after client navigation does not establish what a direct request delivered.
Inspect a normal direct request and a request with a relevant sharing-crawler user agent. Read each complete response. In a browser test, wait for the expected title and inspect the resolved document rather than assuming every generated tag must already exist in the initial head snapshot.
Check the installed version and the project's htmlLimitedBots configuration before changing delivery behavior. A user-agent test exercises that response path; it does not reproduce the real crawler's network access, rendering service or indexed view.
Prefer server-provided content and stable page identities to an English document that client effects later rewrite. Google can process JavaScript, but its JavaScript SEO guidance distinguishes crawling, rendering and indexing. Keep the canonical consistent through those stages instead of letting separate server and browser locale decisions compete.
Test the deployed relationships, not just tag presence#
Create a small set of representative records: the translated cup workshop, an Arabic-only course, an unpublished Arabic draft and an old slug with a redirect. Run the checks against a production build and repeat the public response checks after deployment.
For each published variant, assert the exact title, description, canonical URL, language alternate mapping and Open Graph locale. Then request every alternate target and verify the content identity and return mapping. Compare the page's preferred URL with its sitemap entry and its internal language link.
The expected data should be independently reviewable. If the test imports the same helper that accidentally pairs two unrelated workshops, it can faithfully confirm the bug. Keep a small expected relationship table in test fixtures and review it when content routes change.
Normalize URL representation before comparison. An Arabic path can appear percent-encoded in serialized URLs. The URL API provides parsing and serialization for consistent comparisons, including the host, pathname and relevant query policy. Do not treat a visual difference between a readable Arabic path and its encoded representation as proof of a different destination.
Test locale state too. Visit English, then open the Arabic URL in the same session; repeat in the opposite order. Compare the body and metadata. If either depends on visit order, inspect locale inputs to the CMS request, client provider and cache keys. The route's language prefix cannot protect a data helper that returns a shared English record.
For translation updates, verify the body, generated metadata and sitemap after the intended revalidation operation. They may have different caches. A fresh browser does not clear a server-side sitemap or data cache.
Include one missing-record assertion. Check the missing-page content and indexing behavior, not merely whether the request completed. Include one negative publication assertion too: the Arabic draft should not become a public alternate or sitemap entry just because its path is known internally.
These tests should fail with a precise relationship: the requested URL, expected content identity, actual canonical and mismatched target. That is more actionable than a generic “SEO failed” message or a snapshot containing hundreds of unrelated tags.
Compare the live page with the indexed page#
After a fix reaches production, inspect the exact Arabic URL in Google Search Console's URL Inspection tool. Compare the indexed information with a live test. Check the reported canonical information, crawl details and rendered evidence where available.
Those views answer different questions. The indexed report can describe an earlier crawl; the live test inspects the current page and does not guarantee indexing. A request for indexing is not a promise that the page will appear or that Google will display the submitted title verbatim.
If the current response still identifies English, fix the application. If the current response and relationships are correct but the indexed report predates the deployment, preserve that distinction in the issue instead of repeatedly altering metadata without new evidence.
Record the release, public URL, translation publication time and the response you verified. Keep the English counterpart in the report when the failure concerns a canonical or alternate relationship. Arabic SEO defects often need two URLs to explain them.
A free Ritla scan of the deployed Arabic workshop page can flag a canonical pointing at another locale or an alternate set lacking Arabic; it does not establish whether Google has indexed the correction. Follow with testing Arabic releases to keep translation publication and route changes in the release process, and use Arabic localization testing when the tags are Arabic but the workshop itself is not fully translated.