Was ist das ASTRO-Dateiformat?
Eine .astro-Datei ist eine Komponente, die von Astro verwendet wird, einem Open-Source-Web-Framework für inhaltsorientierte Websites wie Blogs, Dokumentationen und Marketingseiten. Fred K. Schott entwickelte Astro im Jahr 2021, und es erreichte im August 2022 die stabile Version 1.0. Das Projekt wird nun unter der MIT-Lizenz gepflegt, nachdem Cloudflare die Astro Technology Company im Januar 2026 übernommen hat.
Jede Datei besteht aus zwei Teilen, die durch einen --- Code-Block (Code Fence) getrennt sind. Über dem Block befindet sich das Komponentenskript, auch Frontmatter genannt, das in JavaScript oder TypeScript geschrieben ist. Es wird zur Build-Zeit ausgeführt, um andere Komponenten zu importieren, Daten abzurufen und Variablen zu deklarieren. Unterhalb des Blocks befindet sich das Template, ein HTML-ähnlicher Block, der {}-Ausdrücke, <slot />-Platzhalter sowie Scoped <style>- und <script>-Tags akzeptiert. Die Syntax ist eine Erweiterung von .html und liest sich ähnlich wie JSX, verwendet jedoch standardmäßige Kebab-Case-Attribute.
Astro rendert Komponenten im Voraus zu HTML und liefert standardmäßig kein clientseitiges JavaScript aus. Interaktive Teile werden selektiv über die Islands-Architektur mithilfe von client:*-Direktiven auf Framework-Komponenten hinzugefügt.
Sicherheit
RISIKO: LOWAn .astro file is human-readable source text and cannot run on its own by double-clicking. It only executes when compiled by the Astro toolchain during a build. As with any project source, its frontmatter can contain JavaScript, so review files from untrusted repositories before running npm install or a build, since build scripts and dependencies (not the .astro file itself) are the real risk.
Formatdetails
kurz gefasst- ASTRO-VISION LifeSign / horoscope data - Some astrology software has used .astro for chart or profile data files. Unrelated to the web framework.
- Generic astronomy/astrology data exports - Occasionally seen as an ad hoc extension for star-chart or ephemeris data in niche tools.
Programme zum Öffnen von ASTRO-Dateien
.astro files. .astro components. npm run dev or astro build to compile .astro files into HTML and preview the site. .astro files with full language support. astro dev and astro build in Terminal to run and compile the project. .astro files. npm run dev or npx astro build from the terminal to serve or compile .astro files. Technische Details
technische Spezifikation| Encoding | UTF-8 plain text |
| Byte order | Not applicable (text) |
| Container | None; single source file |
| Typical size | A few hundred bytes to tens of kilobytes |
| Structure | Two sections separated by a --- code fence: an optional component script (frontmatter) written in JavaScript/TypeScript that runs at build time or on the server, followed by a component template made of HTML-like markup with {} expressions, directives, <slot />, <style> and <script> tags. |
| Integrity | None built in |
| Platforms | Windows, macOS, Linux |
| Notes | Astro components render to HTML ahead of time and ship no client-side JavaScript runtime by default. Interactive framework components can be hydrated selectively using client:* directives (the islands architecture). The Astro compiler parses .astro files and outputs HTML plus any scoped CSS and hydration code. |
| Syntax Basis | Superset of HTML, close to JSX but using standard kebab-case HTML attributes |
| Runtime | Server/build-time rendering; no default client runtime |
| Language Support | JavaScript and TypeScript in the frontmatter, including top-level await |
| Veröffentlicht | 2021 |
| Neueste Version | Astro 6 (March 2026) |
| Spezifikation | docs.astro.build |
ASTRO-Konvertierungen
Community Q&A
von Nutzern gefragtNoch keine Fragen - stellen Sie die erste Frage zu ASTRO-Dateien.
Häufig gestellte Fragen
Wie öffne ich eine .astro-Datei?
Kann ich eine .astro-Datei in einem Browser anzeigen?
npm run dev aus oder erstellen es mit astro build, und Astro wandelt die Komponente in HTML um, das der Browser dann anzeigt.Welches Programm erstellt .astro-Dateien?
.astro-Dateien enthalten.Ist eine .astro-Datei dasselbe wie HTML?
Warum hat meine .astro-Datei JavaScript am Anfang?
----Linien ist das Komponentenskript oder Frontmatter. Er wird zur Build-Zeit ausgeführt, um Komponenten zu importieren, Daten abzurufen und Variablen zu setzen, die im darunter liegenden Template verwendet werden.