Start an Astro project

Configure Astro

Use the Astro configuration for site-wide build decisions, integrations, URL information, and output behavior.

8 minute lesson

~~~

A typical configuration imports defineConfig:

import { defineConfig } from 'astro/config'

export default defineConfig({
  site: 'https://notes.flaviocopes.com'
})

The site value gives Astro the deployment origin for features that need absolute URLs, such as sitemap entries and canonical URLs.

Integrations, redirects, output behavior, adapter settings, and build options also belong here. This file runs in the Astro toolchain, not in the visitor’s browser.

Configuration changes can affect every route. Add one setting at a time and keep the reason close to the change.

Prefer the smallest configuration that expresses a real requirement. Defaults are easier to maintain than copied settings whose purpose is unclear.

Do not place runtime secrets in values that will be serialized into generated HTML or client bundles. Server-side configuration does not make every value used from it private.

Set site, build the project, and inspect one generated absolute URL.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →