Skip to content
FA

How a bilingual Astro static site publishes and rolls back

By Arman Hosseini 6 min read FA

The Persian right-to-left homepage of arman-hosseini.ir

The hard part of publishing a personal Astro website is rarely the markup — it is the journey an idea takes from a private note to a public URL, and whether you can undo that journey safely. This walkthrough follows the path through this repository: where entries live, how the metadata layer is assembled, what the admin service can change, and how a build becomes visible or is reverted. The high-level tour lives on the project page; this article goes one level down.

Why is this site published as static HTML?

Because nearly everything it serves is prose. A file compiled once at build time answers faster and costs less than a page rendered on every request, and it arrives complete — no JavaScript needed for a crawler to read it. Astro compiles each route to HTML ahead of time, so a request is answered straight from nginx with no per-request rendering or database lookup.

The only client-side JavaScript is a handful of lines for the theme toggle and a privacy-friendly page-view beacon. There is no client framework, no hydration and no third-party script in the page.

How do Astro content collections model the pages?

Content lives as Markdown and MDX files under src/content/projects/{en,fa} and src/content/journal/{en,fa}. The schema in src/content.config.ts validates every file, and the collection id is derived from the file path with the extension stripped, so en/foo and fa/foo never collide.

Every entry shares a base frontmatter — title, date, lang, tags, summary, draft — plus optional SEO fields: seoTitle, seoDescription, keywords, image, imageAlt, schemaType, noindex, canonical, updated and faq. Project entries add tagline, highlights, featured, span and links.

---
title: "Example entry"
date: "2026-10-10"
lang: "en"
summary: "One-sentence answer shown as the quick-answer block."
tags: ["Astro"]
draft: false
---

A file is only rendered when it is not a draft and its dashboard status is published; otherwise it is skipped during the build. Dashboard edits are never written into the content file — they go to content-meta/overrides.json, keyed collection/lang/slug, and are merged in src/lib/content.ts.

How does the SEO/AEO layer work?

Every page carries its own title, description, keywords, canonical URL and optional noindex. src/lib/seo.ts builds the Open Graph and Twitter metadata and a JSON-LD @graph that includes the site’s Person entity and the node selected by schemaType — Article, TechArticle, HowTo, FAQPage, SoftwareApplication, SoftwareSourceCode, CreativeWork or WebPage.

For answer engines, the build also emits machine-readable companions: sitemap.xml with hreflang alternates and lastmod, robots.txt, llms.txt, per-language RSS feeds and a web manifest. Each entry’s summary is rendered as a “quick answer” block, and any frontmatter faq entries become a visible FAQ section with matching FAQPage structured data.

title / description / keywords / canonical
        │
        ▼
src/lib/seo.ts ──► Open Graph + Twitter cards
        │
        ▼
JSON-LD @graph  (Person, WebSite, page node, BreadcrumbList, FAQPage)

How does the admin service publish a page?

admin/server.mjs is a Node HTTP server with no npm dependencies. It exposes a fixed route table; sensitive routes require a session, and every write requires a CSRF header. Authentication uses a scrypt password hash, an HttpOnly SameSite=Strict session cookie, a login rate limit and a strict Content-Security-Policy.

The dashboard is served under /admin/. It lists pages with filters, edits per-page SEO with a live preview, manages media and translations, toggles draft/disabled status with undo, and shows analytics, build logs and one-click rollback. Each page has a live check: the dashboard confirms whether the page is present in the current release and whether the public URL answers.

The companion Obsidian plugin, Vergo MDX Studio, authenticates with a revocable bearer token against the /api/studio/ endpoints. Media is staged and must match its SHA-256-derived name. Every page must compile and obey the site’s MDX rules; a broken page is rejected with the file and line number. Valid pages land in the dashboard inbox and nothing goes live until it is approved.

The full pipeline

Obsidian → /api/studio → Inbox → approve → astro build → releases/<ts> → current symlink.

How do atomic releases and rollbacks work?

When a build starts, the admin service runs the build command into a fresh directory under the site folder, then checks that it produced an index.html. Only on success does it move the output into releases/<timestamp> and replace the current symlink — by creating a new symlink beside the old one and renaming over it, which is atomic on POSIX filesystems.

nginx serves .../current, so the live site switches in one step. A failed build is deleted and the live site is never touched. The service keeps the last five releases, so a rollback is a single action that points current at an older release.

build → .build/<ts>  ──success──►  releases/<ts>  ──►  current (symlink; atomic rename)
                    └──failure──►  deleted; live site unchanged

What is not allowed in an MDX page?

The admin service validates every Obsidian submission and every dashboard edit against admin/lib/policy.mjs, rejecting the page with a file, line and column on any violation:

  • Only the built-in components — any other <Component> name is rejected.
  • No imports — pages need nothing beyond the built-ins.
  • No export and no server-side APIs (process, require, fetch, import(), …), because MDX is compiled on the server.
  • Code inside fenced blocks is ignored by the rules, so an example like import x from "y" is fine to show.

This is defence in depth, not a sandbox: every page still passes through a human approval. And because the site is static, there is no React and no client-side interactivity, so runtime handlers such as onClick are not available.

What are the limits?

  • No client framework. Content cannot rely on browser-side interactivity; pages are HTML.
  • Translations need a link. An English and a Persian page get hreflang and the language switcher only when they share a translationKey.
  • Single operator. The admin service is built for one author with one password and a local data directory, not for multi-user hosting.
  • Content is file-based. Publishing means a rebuild; there is no per-request editing.

What should you remember?

  • arman-hosseini.ir is a bilingual (English and Persian) static site built with Astro 7 and Tailwind 4, with no client framework.
  • Content is file-based and schema-validated; the SEO/AEO layer turns each entry into metadata, an Open Graph card and JSON-LD.
  • A zero-dependency Node admin service edits content and builds atomic releases, keeping the last five for rollback.
  • Pages arrive from Obsidian, are validated against a strict MDX policy, and wait for approval before going live.
  • Start from the project page, read about the author, or browse the projects and the homepage.

References

Frequently asked

Why is this site published as static HTML?

A page compiled ahead of time is cheaper to deliver than one rendered per request, and the finished file is equally readable to a browser, a search crawler and an AI answer engine.

Does the site ship a JavaScript framework?

No. The output a visitor downloads is HTML and CSS; the only scripts handle the light/dark theme switch and an anonymous page-view counter.

How does a note become a live page?

An editor sends the MDX and its media to the admin service, the page waits in an inbox, and approving it triggers a build whose result is published as a new release.

How are the English and Persian versions connected?

The two files share one translationKey, which the layout turns into hreflang alternates, a language switcher and a workTranslation link in the structured data.

What may a page contain?

Markdown plus the site's own Callout, Card, Tabs/Tab, YouTube, AudioPlayer and VideoPlayer components. Imports, exports and server-side APIs are rejected before anything is published.

Can it host several authors?

Not by design. The admin service assumes one password, one local data directory and a file-based workflow, so it fits a single writer rather than a multi-user team.

Keep reading

cd ../journal