Skip to content

Project Structure

project-root/
├── public/ # Static assets (unprocessed)
│ ├── robots.txt
│ ├── favicon.svg
│ └── fonts/
├── src/
│ ├── assets/ # Images/assets for Astro to process
│ ├── components/ # .astro and framework components
│ ├── content/ # Content collection data files
│ │ └── blog/
│ │ ├── post-1.md
│ │ └── post-2.md
│ ├── layouts/ # Page layout components
│ ├── pages/ # File-based routing
│ │ ├── index.astro
│ │ ├── about.astro
│ │ └── blog/
│ │ └── [...slug].astro
│ ├── styles/ # Global CSS/Sass
│ ├── middleware.ts # Request middleware
│ ├── actions/ # Server actions
│ │ └── index.ts
│ └── content.config.ts # Collection definitions
├── astro.config.mjs # Astro configuration
├── tsconfig.json # TypeScript config
└── package.json

Every file creates a route:

FileRoute
src/pages/index.astro/
src/pages/about.astro/about
src/pages/blog/index.astro/blog
src/pages/blog/[slug].astro/blog/:slug
src/pages/[...path].astroCatch-all

Supported file types: .astro, .md, .mdx, .html, .ts/.js (API endpoints)

Convention (not required). Holds reusable .astro components and framework components (.jsx, .vue, .svelte).

Convention (not required). Layout components that wrap pages with common structure (head, nav, footer).

Convention for content collection data files (Markdown, JSON, YAML). Referenced by loaders in content.config.ts.

Static files served as-is. No processing, no bundling. Use for:

  • Fonts
  • robots.txt, manifest.json
  • Files that need a predictable URL
LocationProcessingUse for
src/assets/ or src/images/Optimized, hashed filenamesImages you import in components
public/None, copied as-isFonts, favicons, files needing stable URLs

Required for integrations, adapters, and build config. Supports .js, .mjs, .cjs, .ts.

Required for editor support. Extend Astro’s base config:

{
"extends": "astro/tsconfigs/strict"
}

Options: base, strict, strictest

Defines content collections and their schemas. Lives at project root src/content.config.ts.

FilePurpose
src/middleware.tsRequest middleware (runs before pages)
src/actions/index.tsType-safe server actions
src/env.d.tsTypeScript environment declarations
.astro/Generated types and collection schemas (gitignored)