All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server at localhost:3000 |
npm run build |
Build your production site to ./dist/ |
npm run preview |
Preview your build locally, before deploying |
npm run astro ... |
Run CLI commands like astro add , astro check |
npm run astro --help |
Get help using the Astro CLI |
To deploy your site to production, check out our Deploy an Astro Website guide.
Feel free to check our documentation or jump into our Discord server.
Astro uses frontmatter in Markdown pages to choose layouts and pass properties to those layouts. If you are using the default layout, you can customize the page in many different ways to optimize SEO and other things. For example, you can use the title
and description
properties to set the document title, meta title, meta description, and Open Graph description.
---
title: Example title
description: Really cool docs example that uses Astro
---
Note the top-level en
key: This is needed for multi-language support. You can change it to whatever language you'd like, or add new languages as you go. More details on this below.
The Astro docs template supports multiple languages out of the box. The default theme only shows en
documentation, but you can enable multi-language support features by adding a second language to your project.
To add a new language to your project, you'll want to extend the current src/content/docs/[lang]/...
layout:
📂 src/content/docs
┣ 📂 en
┃ ┣ 📜 page-1.md
┃ ┣ 📜 page-2.md
┃ ┣ 📜 page-3.astro
+ ┣ 📂 es
+ ┃ ┣ 📜 page-1.md
+ ┃ ┣ 📜 page-2.md
+ ┃ ┣ 📜 page-3.astro
Last step: you'll need to add a new entry to your sidebar, to create the table of contents for that language. While duplicating every page might not sound ideal to everyone, this extra control allows you to create entirely custom content for every language.
Make sure the sidebar
link
value points to the correct language!
// src/config.ts
export const SIDEBAR = {
en: [
{ text: 'Section Header', header: true, },
{ text: 'Introduction', link: 'en/introduction' },
// ...
],
+ es: [
+ { text: 'Encabezado de sección', header: true, },
+ { text: 'Introducción', link: 'es/introduction' },
+ // ...
+ ],
};
// ...