Quick start
This guide will walk you through creating your first Astro project, understanding its structure, and deploying it to the web.Create a new project
Follow the setup wizard
The
create-astro wizard will guide you through setup. For this tutorial, choose:Understand the project structure
Look inside your new Astro project and you’ll see the following folders and files:src/pages/
src/pages/
This is where your website pages live. Astro looks for
.astro, .md, or .mdx files here and automatically creates routes based on the file structure.src/pages/index.astro→yoursite.com/src/pages/about.astro→yoursite.com/aboutsrc/pages/blog/first-post.md→yoursite.com/blog/first-post
src/components/
src/components/
This is where you’ll put reusable components. There’s nothing special about this directory, but it’s a common convention for organizing your Astro, React, Vue, Svelte, or other UI framework components.
src/layouts/
src/layouts/
Another common directory for layout components that wrap your page content. This is also just a convention.
public/
public/
Static assets like images, fonts, and files that don’t need to be processed. These are served as-is and can be referenced directly.
astro.config.mjs
astro.config.mjs
Your Astro configuration file. This is where you configure integrations, build options, server options, and more.
package.json
package.json
Your project’s dependencies and scripts. Astro provides these scripts by default:
dev: Start the development serverbuild: Build for productionpreview: Preview your production build locally
tsconfig.json
tsconfig.json
TypeScript configuration. Even if you’re not using TypeScript, this file helps editors provide better IntelliSense.
Start the dev server
Astro comes with a built-in development server that has everything you need for project development.The dev server features hot module replacement (HMR), so changes you make to your files will automatically update in the browser without needing to refresh.
Make your first changes
Let’s customize your homepage:Open the index page
Open
src/pages/index.astro in your text editor. You’ll see something like this:src/pages/index.astro
Add some content
Update your page with custom content:Save the file and check your browser - you should see the changes instantly!
src/pages/index.astro
Create a layout component
To avoid repeating the same HTML structure on every page, let’s create a reusable layout:Create a layout component
Create The
src/layouts/Layout.astro:src/layouts/Layout.astro
<slot /> element is where child content will be injected.Add another page
Let’s add an about page to demonstrate routing:src/pages/about.astro
http://localhost:4321/about to see your new page!
Add navigation
Create a navigation component to link between pages:Build for production
When you’re ready to deploy your site, create a production build:By default, Astro builds a static site (Static Site Generation or SSG). All pages are pre-rendered to HTML at build time for maximum performance.
Deploy your site
Astro’s static output can be deployed to any static hosting provider:Netlify
Deploy with zero configuration using Netlify Drop or the Netlify CLI
Vercel
Import your Git repository for automatic deployments on every push
Cloudflare Pages
Connect your repository for instant deployments
GitHub Pages
Deploy directly from your GitHub repository with Actions
Example: Deploy to Netlify
Create a Netlify account
Sign up at netlify.com
Configure build settings
Netlify should auto-detect these settings:
- Build command:
npm run build - Publish directory:
dist
Next steps
Congratulations! You’ve created your first Astro site. Here’s what to explore next:Add integrations
Enhance your site with React, Tailwind CSS, and more
Content collections
Learn to manage content with type safety
Islands architecture
Master Astro’s approach to partial hydration
API reference
Dive deep into Astro’s configuration and APIs