ASTRO ファイル形式とは?
.astroファイルは、ブログ、ドキュメント、マーケティングページなどのコンテンツ重視のサイト向けのオープンソースウェブフレームワークであるAstroで使用されるコンポーネントです。Fred K. Schott氏が2021年にAstroを作成し、2022年8月に安定版1.0に到達しました。2026年1月にCloudflareがAstro Technology Companyを買収した後、現在はMITライセンスの下でプロジェクトが維持されています。
各ファイルは、---のコードフェンスで区切られた2つの部分で構成されています。フェンスの上部はコンポーネントスクリプト(フロントマター)で、JavaScriptまたはTypeScriptで記述されます。これはビルド時に実行され、他のコンポーネントのインポート、データの取得、変数の宣言を行います。フェンスの下部はテンプレートで、{}式、<slot />プレースホルダー、およびスコープ化された<style>や<script>タグを受け入れるHTMLライクなブロックです。構文は.htmlのスーパーセットであり、JSXによく似ていますが、標準的なケバブケース(kebab-case)の属性を使用します。
Astroはコンポーネントを事前にHTMLにレンダリングし、デフォルトではクライアントサイドのJavaScriptを送信しません。インタラクティブな部分は、フレームワークコンポーネントにclient:*ディレクティブを使用する「アイランドアーキテクチャ」を通じて選択的に追加されます。
セキュリティと安全性
リスク: 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.
形式の詳細
概要- 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.
ASTRO ファイルを開くプログラム
.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. 技術的詳細
詳細仕様| 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 |
| リリース日 | 2021 |
| 最新バージョン | Astro 6 (March 2026) |
| 仕様書 | docs.astro.build |
ASTRO の変換
コミュニティ Q&A
ユーザーからの質問まだ質問はありません。ASTRO ファイルについて最初の質問をしてみましょう。
よくある質問
.astroファイルはどうやって開きますか?
ブラウザで.astroファイルを表示できますか?
npm run devでプロジェクトを実行するか、astro buildでビルドを行うと、AstroがコンポーネントをHTMLに変換し、それをブラウザが表示できるようになります。.astroファイルを作成するプログラムは何ですか?
.astroファイルが含まれたスタータープロジェクトを生成できます。.astroファイルはHTMLと同じですか?
なぜ.astroファイルの先頭にJavaScriptがあるのですか?
---行に挟まれたその上部セクションは、コンポーネントスクリプトまたはフロントマターと呼ばれます。これはビルド時に実行され、コンポーネントのインポート、データの取得、下のテンプレートで使用する変数の設定を行います。