Content Authoring Guidelines
This document provides guidelines for creating and managing content within projects built with this Astro Performance Starter template.
Getting Started
Section titled “Getting Started”- Content Location: All structured content uses Astro’s Content Collections API in
src/content/ - Validation: Run
pnpm run checkto validate TypeScript and content schemas - Configuration: Content collection schemas are defined in
src/content/config.ts
Content Collections Setup
Section titled “Content Collections Setup”The template includes a basic content collection structure that you can extend:
Blog Collection Example
Section titled “Blog Collection Example”import { defineCollection, z } from 'astro:content';
const blog = defineCollection({ type: 'content', schema: z.object({ title: z.string(), description: z.string(), publishDate: z.date(), author: z.string().optional(), tags: z.array(z.string()).optional(), draft: z.boolean().default(false), }),});
export const collections = { blog };Creating Content
Section titled “Creating Content”- Create collection directory:
src/content/[collection-name]/ - Add content files: Use
.mdor.mdxformat - Include frontmatter: Match your schema requirements
- Validate: Run
pnpm run checkto ensure type safety
Using MDX Components
Section titled “Using MDX Components”The template supports MDX for rich content with React-like components:
---title: "Example Post"description: "Demonstrating MDX components"publishDate: 2024-01-01---
# My Post
Regular markdown content works as expected.
<Image src="./example.jpg" alt="Example image" />
You can also use any Astro components in your MDX files.Image Guidelines
Section titled “Image Guidelines”- Location: Store images next to content files or in
src/assets/ - Optimization: Use the built-in
<Image />component for automatic optimization - Formats: AVIF and WebP are automatically generated
- Alt text: Always include descriptive alt text for accessibility
---import { Image } from 'astro:assets';import myImage from '../assets/example.jpg';---
<Image src={myImage} alt="Descriptive alt text" />Content Workflow
Section titled “Content Workflow”- Plan content structure using Content Collections
- Create schema in
src/content/config.ts - Write content in MDX format with proper frontmatter
- Preview locally with
pnpm dev - Validate with
pnpm run check - Deploy using your preferred hosting platform