Vad är filformatet ASTRO?
En .astro-fil är en komponent som används av Astro, ett ramverk med öppen källkod för innehållsfokuserade webbplatser som bloggar, dokumentation och marknadsföringssidor. Fred K. Schott skapade Astro 2021, och det nådde en stabil version 1.0 i augusti 2022. Projektet underhålls nu under MIT-licensen efter att Cloudflare förvärvade Astro Technology Company i januari 2026.
Varje fil har två delar som delas av en --- kodavgränsare (code fence). Ovanför avgränsaren finns komponentskriptet, eller frontmatter, skrivet i JavaScript eller TypeScript. Det körs vid byggtiden för att importera andra komponenter, hämta data och deklarera variabler. Under avgränsaren finns mallen, ett HTML-liknande block som accepterar {}-uttryck, <slot />-platshållare samt begränsade <style>- och <script>-taggar. Syntaxen är en utökning av .html och påminner mycket om JSX, även om den använder standardattribut i kebab-case.
Astro renderar komponenter till HTML i förväg och skickar som standard ingen JavaScript till klienten. Interaktiva delar läggs till selektivt genom en ö-arkitektur (islands architecture) med hjälp av client:*-direktiv på ramverkskomponenter.
Säkerhet & trygghet
RISK: 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.
Formatdetaljer
i ett nötskal- 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.
Program som öppnar ASTRO-filer
.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. Tekniska detaljer
djup specifikation| 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 |
| Släppt | 2021 |
| Senaste version | Astro 6 (March 2026) |
| Specifikation | docs.astro.build |
ASTRO-konverteringar
Frågor & svar
frågat av användareInga frågor än - bli den första att fråga om ASTRO-filer.
Vanliga frågor
Hur öppnar jag en .astro-fil?
Kan jag se en .astro-fil i en webbläsare?
npm run dev eller bygger det med astro build, och Astro förvandlar komponenten till HTML som webbläsaren sedan visar.Vilket program skapar .astro-filer?
.astro-filer.Är en .astro-fil samma sak som HTML?
Varför har min .astro-fil JavaScript högst upp?
----raderna, är komponentskriptet eller frontmatter. Det körs vid byggtiden för att importera komponenter, hämta data och ställa in variabler som används i mallen nedanför.