Last updated: September 2026 · Reading time: 13 min · By the Best Web Developer team
Quick answer
Astro content collections let you store documentation as Markdown or MDX files, validate every page’s frontmatter with a Zod schema, and query pages with typed functions at build time. The result is a static docs site that ships almost no JavaScript, loads in under a second on mobile, and fails the build before a broken page reaches readers. A typical bilingual build costs SAR 25,000–90,000.
Key takeaways
- A collection is a folder of content plus a schema. The schema turns frontmatter typos into build errors instead of live bugs.
- Since Astro 5, collections use loaders, so the same query API works for local files, a headless CMS or a JSON API.
- Starlight, Astro’s official docs theme, adds sidebar, search and right-to-left support for Arabic on top of collections.
- Well-built Astro docs sites routinely reach mobile LCP under 1.5 seconds because pages are pre-rendered HTML.
- Saudi teams should plan Arabic and English collections side by side, with hreflang and a shared ID for each translated page.
Why documentation teams are moving to Astro content collections
Documentation teams move to Astro content collections because they get the simplicity of Markdown files with the safety of a typed database. Writers keep working in plain text, while developers get compile-time checks, fast static output and full control over layout.
A content collection is a named group of entries, such as docs pages, changelog items or API references, that share one schema and are loaded through one API. In Astro, you define collections in a single configuration file, and every page, sidebar and search index reads from them.
For Saudi software companies, fintechs and government suppliers, a docs site is often the first thing a technical buyer checks. A fast, bilingual, well-organised developer portal signals maturity long before a sales call.
Note: versions and naming
This guide describes the content layer introduced in Astro 5, where collections are declared in a file at src/content.config.ts and each collection names a loader. Older Astro 2–4 projects used a src/content/config.ts file and a type field instead. The ideas are the same, but check the official Astro website and docs for the exact syntax of your version before you copy anything.
How Astro content collections work under the hood
Astro content collections work in three layers: a loader fetches raw entries, a schema validates and types them, and query functions return them to your pages at build time. Understanding those three layers is enough to design a documentation site that scales to thousands of pages.
Layer 1: loaders decide where content comes from
A loader is a function that tells Astro how to find entries. The built-in glob loader reads every Markdown or MDX file that matches a pattern inside a base folder, such as src/content/docs. The file loader reads a single JSON or YAML file, which suits glossaries, FAQ lists or a table of supported countries. Community and custom loaders can pull from Contentful, Sanity, Notion or your own REST endpoint.
Layer 2: schemas turn frontmatter into a contract
Each collection can declare a schema written with Zod, a TypeScript validation library bundled with Astro. For docs, a sensible schema requires a title of at most 70 characters, a description between 50 and 160 characters, a sidebar order number, an optional version tag, a last-reviewed date and an owner field. If a writer forgets the description or types the date wrongly, the build stops and names the file.
Schemas can also reference other collections. A docs page can point to an authors collection or a products collection, and Astro checks that the referenced entry exists. That single feature removes most “orphan page” problems we see in docs audits.
Layer 3: query functions feed pages and navigation
Pages call getCollection to fetch every entry in a collection, optionally with a filter, or getEntry to fetch one entry by its ID. A render function converts the Markdown body into HTML plus a list of headings, which you can use for the “On this page” table of contents. Because all of this runs at build time, the reader receives finished HTML with no database call.
Where Starlight fits
Starlight is Astro’s official documentation theme, built on top of Astro content collections. It gives you a sidebar, full-text search powered by Pagefind, dark mode, versioned-looking navigation, accessible components and built-in internationalisation, including right-to-left layout for Arabic. For most teams, Starlight is the fastest route; a custom build makes sense only when the design must match a strong brand system or the docs sit inside a larger marketing site.
Our process: building a docs site step by step
We build documentation sites in eight steps, from content audit to performance budget. A 60–150 page bilingual docs site usually takes four to eight weeks with this process, most of it spent on content, not code.
- Audit existing content. Export every current page into a spreadsheet with URL, title, owner, last update and monthly visits. Mark each one keep, merge, rewrite or delete. Most docs sites we audit can drop 20–35% of pages.
- Design the information architecture. Group pages into four or five top-level sections, for example Getting started, Guides, API reference, Integrations and Changelog. Limit sidebar depth to three levels.
- Define collections and schemas. Usually one docs collection, one changelog collection and one small data collection for shared items such as error codes or supported regions.
- Set up the folder structure. Use locale folders, such as docs/en and docs/ar, with identical file names so each Arabic page maps to its English twin.
- Migrate content. Convert HTML or wiki pages to Markdown with a script, then fix what the schema rejects. The build error list becomes your migration checklist.
- Add search and navigation. Pagefind indexes the built HTML, so search works offline and costs nothing to host. Generate the sidebar from the order field rather than a hand-edited list.
- Wire SEO and structured data. Unique titles and descriptions come straight from the schema. Add canonical URLs, an XML sitemap, hreflang pairs and TechArticle or FAQPage markup where it fits.
- Set a performance budget and CI checks. Fail the pull request if a page exceeds, for example, 100 KB of JavaScript or if a link checker finds broken internal links.
Pro tip
Put a lastReviewed date and an owner in every schema, then add a small build script that lists pages not reviewed in 180 days. Stale docs cause more support tickets than missing docs, and this costs less than an hour to set up.
Making the site bilingual: Arabic and English
Bilingual docs need more than translated files. Set the dir attribute to rtl on the Arabic layout, use CSS logical properties (margin-inline-start rather than margin-left) so spacing mirrors automatically, and keep code samples left-to-right inside Arabic pages. The W3C guidance on internationalization covers bidirectional text in detail.
Each page pair should output reciprocal hreflang tags for ar-SA and en, plus an x-default. Our free hreflang generator produces the tag set for a page pair so you can compare it with what your layout outputs. Arabic headings also run shorter or longer than English, so test the sidebar with real Arabic titles, not placeholder text.
Highlight: the docs schema checklist we use
Every docs entry in our builds must have: title (max 70 characters), description (50–160), sidebar order, section, locale, a translation key shared by both language versions, owner, lastReviewed date, optional version and a draft flag. Check titles and descriptions against search limits with our meta length checker before you set the schema limits.
Performance: why static docs stay fast
Static docs stay fast because the browser receives pre-built HTML and CSS with little or no JavaScript to parse. On a mid-range Android phone on a 4G connection, that difference is often one to three seconds of load time compared with a client-rendered docs app.
Targets worth setting
Aim well inside Google’s Core Web Vitals thresholds: Largest Contentful Paint at or under 2.5 seconds, Interaction to Next Paint at or under 200 milliseconds and Cumulative Layout Shift at or under 0.1. The web.dev guide to LCP explains what counts as the largest element. In our builds, docs pages built with Astro content collections typically land between 0.8 and 1.6 seconds LCP on mobile field data, with CLS close to zero.
Where speed still gets lost
- Web fonts: loading four weights of an Arabic font and four of a Latin font can add 400 KB. Subset fonts and load two weights each.
- Syntax highlighting in the browser: highlight code at build time with Shiki (built into Astro) rather than a client library.
- Unoptimised screenshots: use Astro’s image component to output AVIF or WebP with fixed dimensions, which also prevents layout shift.
- Chat widgets and analytics: load them after user interaction or on idle. A single support widget can outweigh the entire docs page.
Key benefits of Astro content collections for documentation
The main benefits of Astro content collections are fewer content bugs, faster pages and lower running costs. Each one is measurable within the first quarter after launch.
- Build-time validation: missing titles, invalid dates and broken references fail the build, so they never reach production.
- Type safety in templates: editors in VS Code autocomplete frontmatter fields, and a renamed field shows errors everywhere it is used.
- Near-zero JavaScript: pages are HTML first, which suits readers on mobile data plans and older laptops.
- Git-based workflow: docs changes go through pull requests and review, just like code, with full history.
- Low hosting costs: static hosting for a docs site commonly costs SAR 0–150 a month, compared with SAR 400–1,500 for a managed CMS plan.
“The best docs sites fail loudly at build time so they never fail quietly in front of a customer.”
— Best Web Developer engineering team
Use cases in Saudi Arabia: who needs a fast docs site
In Saudi Arabia, fast documentation sites matter most for fintechs, SaaS vendors, logistics platforms and suppliers integrating with government systems. Each group has technical readers who judge the product by the quality of its docs.
Fintech and payment APIs
Payment and open-banking providers need clear API references, sandbox guides and error-code tables. A data collection for error codes lets the same entries appear in the reference, the troubleshooting guide and the search index without copy-paste drift.
E-invoicing and ERP integrations
Software vendors connecting clients to ZATCA’s FATOORA e-invoicing platform publish step-by-step onboarding guides that change whenever requirements change. A lastReviewed field and version tag make it obvious which instructions are current. Link readers to the official ZATCA website for the rules themselves.
Illustrative case: a Riyadh SaaS vendor rebuilds its developer docs
Challenge: A Riyadh logistics SaaS company ran 210 docs pages on a hosted wiki. Mobile LCP was 4.8 s, 38 pages had no owner, the Arabic section covered only a third of the English content, and support received about 460 “how do I” tickets a month.
What we did: We audited and cut the set to 142 pages, defined three collections with strict schemas, moved to Starlight with Arabic and English locales, and added Pagefind search, hreflang pairs and a CI link check. Budget: SAR 68,000 over seven weeks.
Result: Mobile LCP fell from 4.8 s to 1.2 s, Arabic coverage reached 100% of priority pages, hosting dropped from SAR 1,100 to SAR 90 a month, and “how do I” tickets fell to about 290 a month within one quarter.
Astro vs Docusaurus vs Next.js vs hosted docs platforms
Astro wins on page weight and flexibility, Docusaurus on out-of-the-box versioning, Next.js on app-like features, and hosted platforms on speed of setup. The right choice depends on who writes the docs and how much control you need.
| Option | JavaScript per page | Strengths | Typical build cost (SAR) |
|---|---|---|---|
| Astro + Starlight | Very low | Typed collections, RTL support, any UI framework for islands | 25,000–90,000 |
| Docusaurus | Moderate (React app) | Built-in doc versioning, large plugin ecosystem | 25,000–85,000 |
| Next.js with MDX | Moderate to high | Docs inside a product app, logged-in features | 45,000–150,000 |
| Hosted docs platform | Varies | Launch in days, editor for non-developers | Subscription, often SAR 5,000–40,000 a year |
| WordPress knowledge base | Moderate to high | Familiar editor, easy for marketing teams | 15,000–60,000 |
Choose Astro content collections when developers or technical writers own the docs, when speed and SEO matter, and when you want Arabic and English under one build. Choose a hosted platform when non-technical staff must publish daily without pull requests. Our web development service builds all of these, so the recommendation follows the brief rather than a favourite tool.
Highlight: what drives the SAR budget
The code is rarely the expensive part. Content migration and Arabic translation review often account for 40–60% of a docs budget. A 100-page English-only migration might cost SAR 25,000–40,000; the same site with professionally reviewed Arabic commonly reaches SAR 55,000–90,000 before 15% VAT.
Vision 2030, AI search and the future of documentation
Vision 2030 is expanding the Saudi software, fintech and digital-government sectors, and every new platform needs documentation that developers and AI assistants can read. Docs built on structured collections are well placed for both.
- AI assistants as readers: developers increasingly ask chat assistants how to use an API. Clear headings, one topic per page and direct answers help assistants quote your docs accurately.
- Machine-readable exports: because entries are typed data, you can generate an llms.txt summary, a JSON search index or an OpenAPI cross-reference from the same collections.
- Arabic-first developer content: as more Saudi developers join the market, Arabic docs become a competitive advantage, not a translation afterthought.
- Accessibility as a requirement: tenders increasingly reference WCAG 2.2, and static HTML with semantic headings is the easiest base to make conformant.
- Structured data: TechArticle and FAQPage markup generated from schema fields keep rich results consistent. Our schema generator helps you draft the JSON-LD pattern before you template it.
Frequently Asked Questions about Astro documentation sites
What are Astro content collections?
Astro content collections are named groups of content, such as docs pages or blog posts, that share one schema and are loaded through one typed API. You declare them in a configuration file, choose a loader for local files or a CMS, and validate frontmatter with Zod. Pages then query entries at build time and render them as static HTML.
Is Starlight better than building a custom Astro docs site?
For most teams, yes. Starlight provides navigation, search, dark mode, accessibility and multilingual support, including right-to-left Arabic, with very little setup. A custom build is worth the extra cost only when the docs must match a distinctive brand system, live inside a larger marketing site, or include unusual interactive features that Starlight’s component overrides cannot cover.
How do I build an Arabic and English docs site in Saudi Arabia?
Create locale folders for Arabic and English with matching file names, set the Arabic layout to right-to-left, and use CSS logical properties so spacing mirrors. Output reciprocal hreflang tags for ar-SA and en on every page pair, keep code samples left-to-right, and have a native Arabic technical writer review terminology. Starlight handles most of this through its locale settings.
Can Astro content collections use a headless CMS?
Yes. Since Astro 5, each collection names a loader, and loaders exist for many headless CMS platforms, databases and APIs. You can also write your own loader in a few dozen lines. The query functions and schemas stay the same, so you can start with Markdown in Git and move some collections to a CMS later without changing page templates.
How much does a documentation website cost in Riyadh?
Typical ranges we quote are SAR 25,000–40,000 for a 100-page English Astro docs migration and SAR 55,000–90,000 for the same site with professionally reviewed Arabic, before 15% VAT. Hosting a static docs site usually costs SAR 0–150 a month. Content audit, migration and translation review drive most of the budget, not the code.
Is Astro good for SEO on documentation pages?
Astro is very good for documentation SEO because pages are pre-rendered HTML that search engines and AI crawlers can read without running JavaScript. Schemas can enforce unique titles and descriptions, and you can generate sitemaps, canonical tags, hreflang and structured data from collection fields. Fast load times also help pages pass Core Web Vitals on mobile.
How do I add search to an Astro docs site?
The simplest option is Pagefind, which indexes your built HTML and runs search in the browser with no server. Starlight includes it by default. Pagefind supports many languages, including Arabic, and loads its index in small chunks, so it stays fast even with thousands of pages. Hosted search services suit very large sites that need analytics.
Getting started with Astro content collections
Astro content collections give documentation teams a rare combination: writers keep plain Markdown, developers get typed and validated data, and readers get pages that load in about a second. Start with a content audit, a strict schema and Starlight, then add Arabic, search and structured data in that order.
For Saudi software and fintech teams, fast bilingual docs are now part of the product. Build them on a foundation that catches mistakes before customers do, and the site will keep up as your platform grows.
Planning a faster docs site?
Send us your current docs URL. We will reply with a content audit summary, a recommended stack and a fixed SAR quote for an Arabic and English build.
Get a free consultation See pricingWant this handled for you?
We build and optimise sites like this every week. Book a free 30-minute call and we will tell you exactly what we would change on yours.
Get a free site review