{
  "id": "build-an-astro-static-seo-site",
  "type": "prompts",
  "category": "prompts",
  "locale": "fr",
  "url": "/fr/prompts/build-an-astro-static-seo-site",
  "title": "Invite pour construire un site SEO statique avec Astro",
  "description": "Invite à copier-coller pour échafauder un site statique Astro entièrement optimisé avec des collections de contenu, un sitemap, des images OG et TypeScript.",
  "tools": [
    "Cursor",
    "Claude Code",
    "Codex",
    "Windsurf"
  ],
  "stack": [
    "Astro",
    "TypeScript",
    "Tailwind"
  ],
  "tags": [
    "astro",
    "seo",
    "typescript",
    "tailwind"
  ],
  "difficulty": "medium",
  "updated": "2026-06-08",
  "markdown": "Donnez ceci à votre agent pour échafauder un site statique Astro prêt pour la production avec des collections de contenu, Tailwind v4, des méta SEO, un sitemap et des images OG par page — sans qu'il invente des intégrations incompatibles ou oublie les balises canoniques.\n\n## Invite principale\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## Notes d'implémentation\n\n- Les collections de contenu d'Astro 5 utilisent `defineCollection` dans `src/content.config.ts`, et non l'ancien chemin `src/content/config.ts` — confirmez que l'agent utilise le bon emplacement.\n- Tailwind v4 est livré comme un plugin Vite ; l'ancien motif `integrations: [tailwind()]` dans `astro.config.ts` est obsolète et provoquera une erreur d'exécution.\n- `getStaticPaths` doit retourner des objets `{ params, props }` ; l'agent retourne parfois des chaînes nues.\n\n## Modifications de fichiers attendues\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## Critères d'acceptation\n\n- `bun run build` se termine avec le code 0 sans erreur de type.\n- Chaque page d'article de blog inclut une URL canonique unique et `og:image` dans le HTML rendu.\n- `/sitemap-index.xml` est généré et contient toutes les URLs des articles de blog.\n- `/robots.txt` existe et interdit `/api/`.\n\n## Commandes de test\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## Erreurs courantes de l'IA\n\n- Installer l'extension obsolète `@astrojs/tailwind` au lieu de `@tailwindcss/vite`.\n- Placer `content.config.ts` dans `src/content/config.ts` (ancien chemin d'Astro 4).\n- Oublier d'appeler `getCollection('blog')` dans `getStaticPaths` — retourner un tableau vide.\n- Ajouter `output: 'server'` dans `astro.config.ts`, ce qui casse l'export statique.\n\n## Invite de correction\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```"
}