This chapter follows What is Astro.
These steps create a new project, explain the files the wizard generates, and show the commands you run day to day. You need a current Node.js LTS release.
Scaffold the project
Run the wizard and answer its prompts for a directory name, a starter template, dependency installation, and Git initialization:
npm create astro@latestPass a template to skip the template prompt. The minimal template is the cleanest starting point for learning; blog adds a content collection, RSS, and a sitemap.
npm create astro@latest -- --template minimalpnpm and Yarn work the same way with pnpm create astro@latest and yarn create astro.
Know the project layout
my-site/├── public/│ └── favicon.svg├── src/│ ├── components/│ ├── layouts/│ ├── pages/│ │ └── index.astro│ └── styles/├── astro.config.mjs├── package.json└── tsconfig.jsonOnly some of these names are special to Astro:
| Path | Role |
|---|---|
src/pages/ |
Required. Each file becomes a route (Routing in Astro). |
public/ |
Copied to the build output unchanged: favicons, robots.txt, files that must keep their exact URL. |
src/content.config.ts |
Defines content collections, when you add them (Content collections in Astro). |
src/middleware.ts |
Runs before rendering requests, when you add it. |
src/actions/ |
Type-safe server functions, when you add them. |
astro.config.mjs |
Project configuration and integrations. |
components/, layouts/, and styles/ are conventions, not rules. Astro processes anything under src/ that a page imports, so you can organize the rest however you like.
Configure Astro
The generated config is nearly empty. Two settings are worth adding early: site, which Astro needs to build absolute URLs for sitemaps, RSS, and canonical links, and trailingSlash, which decides whether /about and /about/ are the same page.
import { defineConfig } from 'astro/config';
export default defineConfig({ site: 'https://example.com', trailingSlash: 'always',});TypeScript works without extra setup. The wizard writes a tsconfig.json that extends one of Astro’s presets (base, strict, or strictest).
Run the development server
npm run devThe dev server starts on http://localhost:4321 with hot module replacement. Edits to .astro files, Markdown, and styles appear without a full reload. The dev toolbar at the bottom of the page shows which components are islands and flags accessibility and performance problems; it never ships to production.
Add integrations
Integrations add UI frameworks, Markdown extensions, adapters, and build features. astro add installs the package and edits the config in one step:
npx astro add reactnpx astro add mdxnpx astro add sitemapReview the config diff it proposes before you accept. You can add several at once: npx astro add react mdx sitemap.
Build, preview, and check
npm run buildnpm run previewnpx astro checkbuild writes the site to dist/. For a static site that folder is the whole deployment. preview serves dist/ locally so you can test the production output, including redirects and trailing-slash behavior that the dev server handles more loosely. astro check runs type checking and diagnostics across .astro files, which tsc alone does not understand; add it to CI next to your tests.
Next: Astro components.