Start here · Lesson 2 of 22 · 10 min

Set up your Astro project

Install Astro, start the dev server, and learn what every folder is for.

1. Check Node

Astro needs Node.js 22.23 or newer. Open a terminal and run:

node -v

If the number is lower, install the current LTS from nodejs.org and open a new terminal.

2. Create the project

npm create astro@latest sunday-supper -- --template minimal

The wizard asks a few questions. Answer:

  • Install dependencies? Yes
  • Initialize a new git repository? Yes

--template minimal gives you an almost empty project. That’s on purpose. You’ll build every piece yourself.

3. Start the dev server

cd sunday-supper
npm run dev

Open http://localhost:4321. You should see a page that says “Astro”. Leave this terminal running. The page reloads every time you save a file.

4. Open it in your editor

Open the sunday-supper folder in VS Code and install the Astro extension when it asks (or search “Astro” in Extensions). It gives you syntax highlighting and autocomplete for .astro files.

What’s in the folder

sunday-supper/
├── public/            ← files copied as-is (favicon, robots.txt, images)
│   └── favicon.svg
├── src/
│   └── pages/         ← every file here becomes a URL
│       └── index.astro
├── astro.config.mjs   ← Astro settings
├── package.json       ← scripts and dependencies
└── tsconfig.json      ← editor type checking

By the end of the course src/ will look like this:

src/
├── components/   Header, Nav, Footer, Section, Card, PostCard
├── content/      blog posts in Markdown
├── data/         nav.json, services.json
├── layouts/      BaseLayout, MarkdownLayout
├── pages/        index, about, blog, 404
└── styles/       global.css

Only src/pages/ has a special meaning. The other folder names are conventions. Astro doesn’t care what you call them, but everyone uses these names, so you should too.

The three commands you’ll use

Command What it does
npm run dev Local dev server with live reload
npm run build Builds the final site into dist/
npm run preview Serves dist/ locally so you can check the real build