1 min read

How to Start a Blog with Astro

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

This article was automatically translated from the original Japanese version and may contain mistranslations. Please refer to the Japanese original for the most accurate 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.

npm create astro@latest

You can configure the project settings interactively.

Start the development server

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

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!

Related Articles