What’s Wrong with Just HTML?
<!-- page1.html -->
<!DOCTYPE html>
<html>
<head>
<title>Page 1</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
</nav>
</header>
<main>
<!-- Only this part is different -->
<h1>Page 1 Content</h1>
</main>
<footer>
<p>© 2025 Netsuki</p>
</footer>
</body>
</html>
Astro Fixes This with “Components”♪
---
// src/components/Header.astro
---
<header>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
</nav>
</header>
---
// src/components/Footer.astro
---
<footer>
<p>© 2025 Netsuki</p>
</footer>
---
// src/pages/page1.astro
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
---
<!doctype html>
<html>
<head>
<title>Page 1</title>
</head>
<body>
<Header />
<main>
<h1>Page 1 Content</h1>
</main>
<Footer />
</body>
</html>
Layouts Make It Even Cleaner♪
---
// src/layouts/BaseLayout.astro
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
const { title } = Astro.props;
---
<!doctype html>
<html>
<head>
<title>{title}</title>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<Header />
<main>
<slot />
<!-- Each page's content goes here -->
</main>
<Footer />
</body>
</html>
---
// src/pages/page1.astro
import BaseLayout from '../layouts/BaseLayout.astro';
---
<BaseLayout title="Page 1">
<h1>Page 1 Content</h1>
<p>Just write the actual content here!</p>
</BaseLayout>
Write Blog Posts in Markdown♪
---
title: Today's Diary
date: 2025-12-08
---
## Breakfast
I had **inari sushi** today!
- Juicy fried tofu pockets
- Perfect vinegared rice
- Ate 3 pieces
So yummy~♪
Builds to Plain HTML
npm run build
JavaScript Only When You Need It
---
import Counter from '../components/Counter.jsx';
---
<!-- This is static HTML (no JS) -->
<Counter />
<!-- This is interactive (sends JS) -->
<Counter client:load />