{
  "id": "build-an-astro-static-seo-site",
  "type": "prompts",
  "category": "prompts",
  "locale": "es",
  "url": "/es/prompts/build-an-astro-static-seo-site",
  "title": "Indicación para crear un sitio SEO estático con Astro",
  "description": "Indicación lista para copiar y pegar para crear un sitio estático Astro completamente optimizado con colecciones de contenido, mapa del sitio, imágenes OG y TypeScript.",
  "tools": [
    "Cursor",
    "Claude Code",
    "Codex",
    "Windsurf"
  ],
  "stack": [
    "Astro",
    "TypeScript",
    "Tailwind"
  ],
  "tags": [
    "astro",
    "seo",
    "typescript",
    "tailwind"
  ],
  "difficulty": "medium",
  "updated": "2026-06-08",
  "markdown": "Entrégueselo a su agente para crear un sitio estático Astro listo para producción con colecciones de contenido, Tailwind v4, meta SEO, mapa del sitio e imágenes OG por página, sin que invente integraciones incompatibles ni omita etiquetas canónicas.\n\n## Indicación principal\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## Notas de implementación\n\n- Las colecciones de contenido de Astro 5 usan `defineCollection` en `src/content.config.ts`, no la ruta antigua `src/content/config.ts` — confirme que el agente usa la ubicación correcta.\n- Tailwind v4 se distribuye como un plugin de Vite; el patrón antiguo `integrations: [tailwind()]` en `astro.config.ts` está obsoleto y causará un error en tiempo de ejecución.\n- `getStaticPaths` debe devolver objetos `{ params, props }`; el agente a veces devuelve cadenas simples.\n\n## Cambios esperados en archivos\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## Criterios de aceptación\n\n- `bun run build` termina con código 0 y sin errores de tipo.\n- Cada página de publicación de blog incluye una URL canónica única y `og:image` en el HTML renderizado.\n- Se genera `/sitemap-index.xml` y contiene todas las URL de las publicaciones del blog.\n- Existe `/robots.txt` y no permite `/api/`.\n\n## Comandos de prueba\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## Errores comunes de la IA\n\n- Instalar el obsoleto `@astrojs/tailwind` en lugar de `@tailwindcss/vite`.\n- Colocar `content.config.ts` en `src/content/config.ts` (ruta antigua de Astro 4).\n- Olvidar llamar a `getCollection('blog')` dentro de `getStaticPaths` — devolviendo un array vacío.\n- Añadir `output: 'server'` a `astro.config.ts`, lo que rompe la exportación estática.\n\n## Indicación correctiva\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```"
}