Pages — AGENTS.md

Package Identity

Astro file-based routing. Each .astro file in pages/ becomes a route.
Rendering: Server-side (SSR) by default. Use export const prerender = true for static pages.


Current Routes

RouteFilePrerendered
/index.astro✅ Yes
/products/[id]products/[id].astro✅ Yes
/wreath-faqwreath-faq.astro✅ Yes

Patterns & Conventions

✅ DO

Static Page Pattern — Copy from index.astro:

---
export const prerender = true;
import BaseLayout from "../layouts/BaseLayout.astro";
import { getCollection } from "astro:content";

const productEntries = await getCollection("products");
---

<BaseLayout>
  <!-- Content -->
</BaseLayout>

Dynamic Route with Static Paths — Copy from products/[id].astro:

---
export const prerender = true;
import BaseLayout from "../../layouts/BaseLayout.astro";
import { getCollection } from "astro:content";
import type { Product } from "../../types";

export async function getStaticPaths() {
  const productEntries = await getCollection("products");
  return productEntries.map((entry) => ({
    params: { id: entry.id },
    props: { product: { ...entry.data, id: entry.id } as Product }
  }));
}

const { id } = Astro.params;
const { product } = Astro.props;
---

<BaseLayout
  title={`${product.name} | Ash Mallows Studio`}
  description={product.description}
  ogImage={product.ogImage || product.image}
>
  <!-- Content -->
</BaseLayout>

SEO Props on BaseLayout — Always pass for product/article pages:

<BaseLayout
  title="Page Title | Ash Mallows Studio"
  description="Page description for search engines"
  ogImage="/images/og/page-image.jpg"
  canonicalUrl="https://ashmallowsstudio.com/page-slug"
>

❌ DON’T


Content Collections

Products are managed via Astro Content Collections:

Schema: src/content.config.ts
Data: src/data/products.json

// Fetching products
import { getCollection } from "astro:content";
const products = await getCollection("products");

Page Structure

All pages should follow this structure:

---
export const prerender = true; // For static pages

import BaseLayout from "../layouts/BaseLayout.astro";
// Other imports...

// Data fetching...
---

<BaseLayout title="..." description="...">
  <main>
    <!-- Main content -->
  </main>
  <Footer />
</BaseLayout>

Touch Points / Key Files

PurposeFile
Base layout../layouts/BaseLayout.astro
SEO component../components/astro/SEO.astro
Default SEO data../data/seo.ts
Content collection config../content.config.ts

JIT Index Hints

# List all page routes
find src/pages -name "*.astro" | sed 's|src/pages||' | sed 's|\.astro$||' | sed 's|/index$|/|'

# Find pages using content collections
rg "getCollection" src/pages

# Find pages with prerendering
rg "prerender.*=.*true" src/pages

# Find dynamic routes
find src/pages -name "\[*\].astro"

Adding New Pages

  1. Create .astro file in src/pages/
  2. Add export const prerender = true if static content
  3. Wrap content in <BaseLayout> with SEO props
  4. For dynamic routes, implement getStaticPaths()
  5. Update sitemap if needed (auto-generated via @astrojs/sitemap)

Common Gotchas


Pre-PR Checks

bun build && bun preview

Then verify:

  1. Page loads correctly at the expected route
  2. SEO meta tags render in <head>
  3. No console errors in browser