View All
seo

Hreflang and RTL: Technical SEO for Persian and Pashto Sites

Suliman Hakimi5 min read

Hreflang and RTL SEO for Persian and Pashto sites comes down to two jobs: telling search engines which language and region each page is for (hreflang), and making sure right-to-left pages are marked up and laid out correctly (lang and dir attributes plus RTL-aware CSS). Get both right and Google can show your Dari page to Dari searchers, your Pashto page to Pashto searchers, and a clean, readable layout to all of them.

Key Takeaways

  • Use fa-AF for Dari, ps (or ps-AF) for Pashto, en for English, and add an x-default fallback.
  • Every hreflang set must be complete and reciprocal: each page lists all versions, including itself.
  • Set lang and dir="rtl" on the html element of Dari and Pashto pages, not just on a wrapper div.
  • Use CSS logical properties so one stylesheet works for both left-to-right and right-to-left layouts.
  • Validate with Google Search Console and a crawler after every release.

What Does Hreflang Actually Do?

Hreflang tells search engines that several URLs are equivalent pages in different languages, so they can show the right one to each searcher. It is a hint, not a ranking factor: it will not push a weak page up, but it helps prevent the wrong language version from appearing and stops your translations from being treated as near-duplicates competing with each other.

You can declare hreflang in three places: link elements in the page head, HTTP headers (useful for PDFs), or the XML sitemap. Pick one method and use it consistently. For most Next.js and similar sites, the page head or the sitemap is easiest to generate automatically from your routing.

Which Language Codes Should You Use for Dari and Pashto?

Use ISO 639-1 language codes, optionally followed by an ISO 3166-1 region code. For Afghan sites that usually means:

  • English: en (or en-US, en-GB if you genuinely target one country)
  • Dari: fa-AF, which means Persian as used in Afghanistan. Dari has its own three-letter code (prs), but hreflang expects the two-letter code, so fa-AF is the safe choice.
  • Pashto: ps, or ps-AF if you want to signal Afghanistan specifically.
  • x-default: the page to show when no language matches, usually your English version or a language-selection page.

A common mistake is using "af" for Afghanistan. In language codes, af means Afrikaans. Another is using a region code alone, such as "AF", which is invalid. The language always comes first, then the region.

How Do You Write a Correct Hreflang Set?

Each page in a group must list every member of the group, including itself, using absolute URLs. If the English page points to the Dari page, the Dari page must point back. Missing return links are the most common error, and when they occur search engines may ignore the annotations.

A complete set for a services page would include four entries: en pointing to the English URL, fa-AF pointing to the Dari URL, ps pointing to the Pashto URL, and x-default pointing to the English URL. All three pages carry the same four entries.

Also check that:

  • Every URL in the set returns a 200 status code, not a redirect or a 404.
  • Each page's canonical tag points to itself. A Dari page canonicalised to the English page cancels its own hreflang.
  • The URLs are not blocked by robots.txt or marked noindex.
  • Only pages that genuinely exist in a language are listed; do not point a Pashto hreflang at an English fallback page.

What Is the Right Way to Mark Up an RTL Page?

Put lang and dir on the html element: lang="fa-AF" dir="rtl" for Dari, lang="ps" dir="rtl" for Pashto. Setting direction on the root means browsers, screen readers and translation tools understand the page correctly from the start. If a single page mixes languages, for example an English product name inside Dari text, mark that span with its own lang, and use dir="auto" or bidi isolation for user-generated content such as reviews and comments.

Google has said it determines a page's language from the visible content rather than the lang attribute, but lang still matters for accessibility, correct font rendering and hyphenation, and it costs nothing to get right.

How Should RTL Layout Be Built?

Build one layout that mirrors itself, using CSS logical properties rather than separate stylesheets. Instead of margin-left and padding-right, use margin-inline-start and padding-inline-end; these flip automatically when dir changes. Flexbox and grid also follow the document direction by default.

A practical RTL checklist:

  1. Mirror navigation, breadcrumbs, sidebars and icons that imply direction, such as arrows and "next" chevrons.
  2. Do not mirror logos, media play buttons, charts with time axes, or phone numbers.
  3. Keep Latin numerals or Eastern Arabic numerals consistent within a page; mixing both looks careless.
  4. Test form fields with mixed content, such as an email address typed into an RTL form.
  5. Choose a web font that supports all Pashto letters, including ښ, ږ, ځ and څ, and subset it for speed.
  6. Check line height: Persian and Pashto script often needs more vertical space than Latin text.

For more on the design side, see our guide to RTL website design best practices.

How Do You Test Hreflang and RTL After Launch?

Crawl the site with an SEO crawler that reports hreflang errors, then confirm in Google Search Console that each language version is indexed. Use URL Inspection on a sample of Dari and Pashto pages to see the canonical Google selected; if it picked the English page instead of the one you declared, your signals are conflicting.

Search a few target queries in each language, ideally from a device in Afghanistan or using a VPN for diaspora markets, and confirm the right version appears. Repeat these checks after every redesign or CMS change, because templates are where hreflang usually breaks. Our technical SEO audit checklist includes these steps alongside the rest of a full audit, and the broader strategy is covered in multilingual SEO for Dari, Pashto and English.

Work With Sheen

Sheen builds trilingual websites on Next.js with hreflang, canonicals and RTL layouts generated correctly from the start. Explore our web design services or our SEO services, or contact us at info@sheen.af or +93 784 966 018.


Frequently Asked Questions

Is hreflang a ranking factor?

Not directly. Hreflang does not make a page rank higher; it helps search engines swap in the correct language or regional version of a page that already ranks. The benefit is indirect but real: Dari and Pashto searchers see a page in their own language, which tends to earn more clicks, and your translations stop competing with each other as near-duplicates.

Should I use fa or fa-AF for a Dari website?

Use fa-AF if your Dari content is written for Afghan readers, which is almost always the case for Afghan businesses. It tells search engines the content is Persian as used in Afghanistan. If you also publish a separate Iranian Persian version, label that one fa-IR. Plain fa works as a general fallback, but fa-AF is the more precise and accurate signal.

Do I need an x-default hreflang tag?

It is optional but recommended. x-default tells search engines which page to show when a searcher's language does not match any of your versions, for example someone searching in Turkish or Urdu. Most trilingual Afghan sites point x-default to the English version, or to a simple language-selection page if the homepage asks visitors to choose a language.

Can one stylesheet handle both English and RTL pages?

Yes, if you write it with CSS logical properties such as margin-inline-start, padding-inline-end and inset-inline-start instead of left and right. These follow the dir attribute automatically, so the same rules produce a left-to-right English page and a right-to-left Dari or Pashto page. You will still need small overrides for icons, fonts and line height.


Keep reading

Read More