P PasteCode
Prompt

Prompt zum Erstellen einer statischen Astro-SEO-Seite

Copy-Paste-Prompt zum Erstellen einer voll optimierten statischen Astro-Seite mit Content Collections, Sitemap, OG-Bildern und TypeScript.

CursorClaude CodeCodexWindsurf AstroTypeScriptTailwind
.md .json Schwierigkeit: Mittel Aktualisiert 8. Juni 2026

Geben Sie dies Ihrem Agenten, um eine produktionsreife statische Astro-Seite mit Content Collections, Tailwind v4, SEO-Meta, Sitemap und seitenbezogenen OG-Bildern zu erstellen – ohne dass er inkompatible Integrationen erfindet oder kanonische Tags überspringt.

Haupt-Prompt

Main Prompt
You are scaffolding a new Astro static site. Use Astro 5, TypeScript strict mode,
and Tailwind CSS v4 (via @tailwindcss/vite — NOT the legacy @astrojs/tailwind integration).
Requirements:
- Initialize with `bun create astro@latest` defaults, then layer in:
- A `src/content/blog/` collection with a Zod schema (title, description, pubDate, tags).
- A shared `<BaseLayout>` with `<head>` containing: canonical URL, og:title, og:description,
og:image (per-page), twitter:card, and the Astro `<ViewTransitions />` component.
- `@astrojs/sitemap` integration configured with `customPages` for any dynamic routes.
- A `public/robots.txt` that disallows `/api/` and allows everything else.
- A `/blog/[slug].astro` dynamic route that renders MDX blog posts.
- A `/tags/[tag].astro` route that filters posts by tag.
- Tailwind applied globally via `src/styles/global.css` imported in BaseLayout.
- All components must be `.astro` — no React unless explicitly asked.
- Export a typed `getStaticPaths` for every dynamic route.
- Do NOT install `@astrojs/react`, `next`, or any SSR adapter — this is a static build.
Stop after listing all files you plan to create or modify. Wait for my approval before writing any code.

Implementierungshinweise

  • Astro 5 Content Collections verwenden defineCollection in src/content.config.ts, nicht den alten Pfad src/content/config.ts – stellen Sie sicher, dass der Agent den korrekten Speicherort verwendet.
  • Tailwind v4 wird als Vite-Plugin ausgeliefert; das alte Muster integrations: [tailwind()] in astro.config.ts ist veraltet und führt zu einem Laufzeitfehler.
  • getStaticPaths muss { params, props }-Objekte zurückgeben; der Agent gibt manchmal bloße Zeichenketten zurück.

Erwartete Dateiänderungen

astro.config.ts (new)
src/content.config.ts (new)
src/layouts/BaseLayout.astro (new)
src/pages/index.astro (new)
src/pages/blog/[slug].astro (new)
src/pages/tags/[tag].astro (new)
src/styles/global.css (new)
public/robots.txt (new)
package.json (edited)
tsconfig.json (edited)

Akzeptanzkriterien

  • bun run build wird mit Exit-Code 0 und ohne Typfehler beendet.
  • Jede Blog-Beitragsseite enthält eine eindeutige kanonische URL und og:image im gerenderten HTML.
  • /sitemap-index.xml wird generiert und enthält alle Blog-Beitrags-URLs.
  • /robots.txt existiert und verbietet /api/.

Testbefehle

Terminal window
bun run build
bun run preview
curl -s http://localhost:4321/sitemap-index.xml | grep '<loc>'
curl -s http://localhost:4321/robots.txt
bun run typecheck

Häufige KI-Fehler

  • Installation des veralteten @astrojs/tailwind anstelle von @tailwindcss/vite.
  • Platzierung von content.config.ts unter src/content/config.ts (alter Astro-4-Pfad).
  • Vergessen, getCollection('blog') innerhalb von getStaticPaths aufzurufen – Rückgabe eines leeren Arrays.
  • Hinzufügen von output: 'server' zu astro.config.ts, was den statischen Export unterbricht.

Fix-Prompt

Fix Prompt
The build failed. Check for these issues in order:
1. Tailwind: remove `@astrojs/tailwind` from integrations and add `@tailwindcss/vite` to the
`vite.plugins` array in astro.config.ts.
2. Content config: the file must be at `src/content.config.ts` (not `src/content/config.ts`).
3. `getStaticPaths`: each entry must be `{ params: { slug }, props: { post } }`.
Fix only the broken items. Show me the corrected diff.