Skip to content

How to Start a Blog with Astro

Disnana 1 min read

Learn how to build a fast blog site using the Astro framework.

Automatically translated from Japanese. See the Japanese original for the original wording.

In this article, I’ll introduce the basics of building a blog with Astro.

What is Astro

Astro is a modern framework for building content-focused websites. It’s especially good at static site generation, and one of its standout features is that it performs extremely well.

Key features

  • Island architecture: make only the parts you need interactive
  • Zero JavaScript: by default, it doesn’t send client-side JavaScript
  • Framework-agnostic: you can use what you like, such as React, Vue, Svelte, etc.

How to install

First, let’s create a project.

bash
npm create astro@latest

You can configure the project settings interactively.

Start the development server

bash
npm run dev

This starts a local server, and you can check it in your browser.

Content collections

Since Astro 2.0, a feature called content collections has been added. With it, you can manage Markdown and MDX files in a type-safe way.

Configuration example

typescript
import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
  schema: z.object({
    title: z.string(),
    date: z.date(),
    tags: z.array(z.string()),
  }),
});

Summary

Astro is a fast and easy-to-use framework. Give it a try!

Build a lightning-fast blog with Astro Web Performance Optimization Basics MDX Syntax Guide - How to Write an Article