{
  "id": "build-an-astro-static-seo-site",
  "type": "prompts",
  "category": "prompts",
  "locale": "de",
  "url": "/de/prompts/build-an-astro-static-seo-site",
  "title": "Prompt zum Erstellen einer statischen Astro-SEO-Seite",
  "description": "Copy-Paste-Prompt zum Erstellen einer voll optimierten statischen Astro-Seite mit Content Collections, Sitemap, OG-Bildern und TypeScript.",
  "tools": [
    "Cursor",
    "Claude Code",
    "Codex",
    "Windsurf"
  ],
  "stack": [
    "Astro",
    "TypeScript",
    "Tailwind"
  ],
  "tags": [
    "astro",
    "seo",
    "typescript",
    "tailwind"
  ],
  "difficulty": "medium",
  "updated": "2026-06-08",
  "markdown": "Geben Sie dies Ihrem Agenten, um eine produktionsreife statische Astro-Seite mit\nContent Collections, Tailwind v4, SEO-Meta, Sitemap und seitenbezogenen OG-Bildern zu erstellen –\nohne dass er inkompatible Integrationen erfindet oder kanonische Tags überspringt.\n\n## Haupt-Prompt\n\n```txt title=\"Main Prompt\"\nYou are scaffolding a new Astro static site. Use Astro 5, TypeScript strict mode,\nand Tailwind CSS v4 (via @tailwindcss/vite — NOT the legacy @astrojs/tailwind integration).\n\nRequirements:\n- Initialize with `bun create astro@latest` defaults, then layer in:\n  - A `src/content/blog/` collection with a Zod schema (title, description, pubDate, tags).\n  - A shared `<BaseLayout>` with `<head>` containing: canonical URL, og:title, og:description,\n    og:image (per-page), twitter:card, and the Astro `<ViewTransitions />` component.\n  - `@astrojs/sitemap` integration configured with `customPages` for any dynamic routes.\n  - A `public/robots.txt` that disallows `/api/` and allows everything else.\n  - A `/blog/[slug].astro` dynamic route that renders MDX blog posts.\n  - A `/tags/[tag].astro` route that filters posts by tag.\n  - Tailwind applied globally via `src/styles/global.css` imported in BaseLayout.\n- All components must be `.astro` — no React unless explicitly asked.\n- Export a typed `getStaticPaths` for every dynamic route.\n- Do NOT install `@astrojs/react`, `next`, or any SSR adapter — this is a static build.\n\nStop after listing all files you plan to create or modify. Wait for my approval before writing any code.\n```\n\n## Implementierungshinweise\n\n- Astro 5 Content Collections verwenden `defineCollection` in `src/content.config.ts`, nicht den alten\n  Pfad `src/content/config.ts` – stellen Sie sicher, dass der Agent den korrekten Speicherort verwendet.\n- Tailwind v4 wird als Vite-Plugin ausgeliefert; das alte Muster `integrations: [tailwind()]` in\n  `astro.config.ts` ist veraltet und führt zu einem Laufzeitfehler.\n- `getStaticPaths` muss `{ params, props }`-Objekte zurückgeben; der Agent gibt manchmal bloße Zeichenketten zurück.\n\n## Erwartete Dateiänderungen\n\n```txt\nastro.config.ts                          (new)\nsrc/content.config.ts                    (new)\nsrc/layouts/BaseLayout.astro             (new)\nsrc/pages/index.astro                    (new)\nsrc/pages/blog/[slug].astro              (new)\nsrc/pages/tags/[tag].astro              (new)\nsrc/styles/global.css                    (new)\npublic/robots.txt                        (new)\npackage.json                             (edited)\ntsconfig.json                            (edited)\n```\n\n## Akzeptanzkriterien\n\n- `bun run build` wird mit Exit-Code 0 und ohne Typfehler beendet.\n- Jede Blog-Beitragsseite enthält eine eindeutige kanonische URL und `og:image` im gerenderten HTML.\n- `/sitemap-index.xml` wird generiert und enthält alle Blog-Beitrags-URLs.\n- `/robots.txt` existiert und verbietet `/api/`.\n\n## Testbefehle\n\n```bash\nbun run build\nbun run preview\ncurl -s http://localhost:4321/sitemap-index.xml | grep '<loc>'\ncurl -s http://localhost:4321/robots.txt\nbun run typecheck\n```\n\n## Häufige KI-Fehler\n\n- Installation des veralteten `@astrojs/tailwind` anstelle von `@tailwindcss/vite`.\n- Platzierung von `content.config.ts` unter `src/content/config.ts` (alter Astro-4-Pfad).\n- Vergessen, `getCollection('blog')` innerhalb von `getStaticPaths` aufzurufen – Rückgabe eines leeren Arrays.\n- Hinzufügen von `output: 'server'` zu `astro.config.ts`, was den statischen Export unterbricht.\n\n## Fix-Prompt\n\n```txt title=\"Fix Prompt\"\nThe build failed. Check for these issues in order:\n1. Tailwind: remove `@astrojs/tailwind` from integrations and add `@tailwindcss/vite` to the\n   `vite.plugins` array in astro.config.ts.\n2. Content config: the file must be at `src/content.config.ts` (not `src/content/config.ts`).\n3. `getStaticPaths`: each entry must be `{ params: { slug }, props: { post } }`.\nFix only the broken items. Show me the corrected diff.\n```"
}