Based on the Astro Starter Kit: Docs Site. New to Astro?
- Check out their documentation.
- Jump into their Discord server.
- Deploy a site to production with the guide, Deploy an Astro Website.
- ✅ Full Markdown support
- ✅ Responsive mobile-friendly design
- ✅ Sidebar navigation
- ✅ Search (powered by Algolia)
- ✅ Multi-language i18n
- ✅ Automatic table of contents
- ✅ Automatic list of contributors
- ✅ (and, best of all) dark mode
git clone https://github.com/t3-oss/create-t3-app.git
cd create-t3-app/www
pnpm i
pnpm dev
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 |
src/config.ts
contains several data objects that describe metadata about your site like title, description, default language, and Open Graph details. You can customize these to match your project.
The theme's look and feel is controlled by a few key variables that you can customize yourself. You'll find them in the public/theme.css
CSS file. If you've never worked with CSS variables before, give MDN's guide on CSS variables a quick read.
This theme uses a "cool blue" accent color by default. To customize this for your project, change the --theme-accent
variable to whatever color you'd like:
/* public/theme.css */
:root {
color-scheme: light;
- --theme-accent: hsla(var(--color-blue), 1);
+ --theme-accent: hsla(var(--color-red), 1); /* or: hsla(#FF0000, 1); */
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.
---
title: Example title
description: Really cool docs example that uses Astro
layout: ../../layouts/MainLayout.astro
---
# Page content...
This uses the title
and description
properties to set the document title, meta title, meta description, and Open Graph description. See src/components/HeadSEO.astro
for more SEO related properties.
The sidebar navigation is controlled by the SIDEBAR
variable in your src/config.ts
file. You can customize the sidebar by modifying this object. A default, starter navigation has already been created for you.
// src/config.ts
export const SIDEBAR = {
en: [
{ text: "Section Header", header: true },
{ text: "Introduction", link: "en/introduction" },
{ text: "Page 2", link: "en/page-2" },
{ text: "Page 3", link: "en/page-3" },
{ text: "Another Section", header: true },
{ text: "Page 4", link: "en/page-4" },
],
};
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
docs. But you can enable multi-language support features. To add a second language to your project, you'll want to extend the layout, src/pages/[lang]/...
:
📂 src/pages
┣ 📂 en
┃ ┣ 📜 page-1.md
┃ ┣ 📜 page-2.md
┃ ┣ 📜 page-3.astro
+ ┣ 📂 es
+ ┃ ┣ 📜 page-1.md
+ ┃ ┣ 📜 page-2.md
+ ┃ ┣ 📜 page-3.astro
You'll also need to add the new language name to the KNOWN_LANGUAGES
map in your src/config.ts
file. This will enable your new language switcher in the site header.