Framework Guides
Easy Implementation
Astro Implementation
Implement GEO in Astro with static site generation and API endpoints
Implementation Overview
Astro provides excellent support for GEO implementation with its static site generation and API routes
Easy
Implementation
2-3
Hours
6
Steps
Astro's static site generation and API routes make it simple to implement all GEO endpoints. The framework's content-focused approach ensures optimal performance and SEO.
Step 1: Create AI.txt Endpoint
Set up the AI crawler permissions endpoint
src/pages/.well-known/ai.txt.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const aiTxt = `# AI.txt for yoursite.com5# This file specifies which JSON endpoints are accessible to AI crawlers67User-agent: *8Allow: /ai/faq.json9Allow: /ai/service.json10Allow: /ai/summary.json1112# Last updated: ${new Date().toISOString().split('T')[0]}`;1314 return new Response(aiTxt, {15 status: 200,16 headers: {17 'Content-Type': 'text/plain; charset=utf-8',18 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',19 },20 });21};
Step 2: Create AI Summary Endpoint
Implement the AI summary endpoint with your site information
src/pages/ai/summary.json.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const summary = {5 version: "1.0",6 lastModified: new Date().toISOString(),7 summary: "Your Astro app provides [services] to [audience] with [benefits]. Built with Astro for optimal performance and SEO.",8 keyFeatures: [9 "Astro framework",10 "Static site generation",11 "Islands architecture",12 "Multi-framework support",13 "TypeScript support"14 ],15 targetAudience: [16 "Content creators",17 "Static site developers",18 "Performance-focused developers"19 ],20 primaryUseCases: [21 "Content sites",22 "Documentation",23 "Marketing sites",24 "Blogs"25 ]26 };2728 return new Response(JSON.stringify(summary), {29 status: 200,30 headers: {31 'Content-Type': 'application/json',32 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',33 },34 });35};
Step 3: Create FAQ Endpoint
Add frequently asked questions for AI systems
src/pages/ai/faq.json.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const faq = {5 version: "1.0",6 lastModified: new Date().toISOString(),7 faqs: [8 {9 question: "What is this Astro app about?",10 answer: "This is a [service type] built with Astro that helps [audience] with [benefits]."11 },12 {13 question: "What technologies are used?",14 answer: "This app is built with Astro, TypeScript, and modern web standards."15 },16 {17 question: "How can I get started?",18 answer: "Visit our documentation or contact us for more information about our services."19 }20 ]21 };2223 return new Response(JSON.stringify(faq), {24 status: 200,25 headers: {26 'Content-Type': 'application/json',27 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',28 },29 });30};
Step 4: Create Service Endpoint
Define your service capabilities and endpoints
src/pages/ai/service.json.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const service = {5 version: "1.0",6 lastModified: new Date().toISOString(),7 service: {8 name: "Your Astro App",9 type: "web-application",10 description: "A modern web application built with Astro",11 url: "https://yoursite.com",12 capabilities: [13 "Static site generation",14 "Islands architecture",15 "Multi-framework support",16 "TypeScript support"17 ],18 endpoints: {19 "home": "/",20 "about": "/about",21 "contact": "/contact",22 "api": "/api"23 },24 supportedFrameworks: ["Astro", "React", "Vue", "Svelte", "TypeScript"],25 contact: {26 "email": "contact@yoursite.com",27 "documentation": "https://yoursite.com/docs"28 },29 pricing: "free",30 availability: "24/7"31 }32 };3334 return new Response(JSON.stringify(service), {35 status: 200,36 headers: {37 'Content-Type': 'application/json',38 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',39 },40 });41};
Step 5: Create Robots.txt Endpoint
Set up general crawler permissions and AI crawler access
src/pages/robots.txt.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const robots = `# Allow legitimate search engines and AI crawlers5User-agent: Googlebot6Allow: /78User-agent: Bingbot9Allow: /1011User-agent: Slurp12Allow: /1314User-agent: DuckDuckBot15Allow: /1617User-agent: Baiduspider18Allow: /1920User-agent: YandexBot21Allow: /2223# Allow AI crawlers for GEO content24User-agent: GPTBot25Allow: /2627User-agent: ChatGPT-User28Allow: /2930User-agent: CCBot31Allow: /3233User-agent: anthropic-ai34Allow: /3536User-agent: Claude-Web37Allow: /3839# Allow social media crawlers40User-agent: facebookexternalhit41Allow: /4243User-agent: Twitterbot44Allow: /4546User-agent: LinkedInBot47Allow: /4849# Block suspicious bots and scrapers50User-agent: *51Disallow: /api/52Disallow: /_astro/53Disallow: /admin/54Disallow: /private/55Disallow: /*.json$56Disallow: /*?*5758# Block common bad bots59User-agent: AhrefsBot60Disallow: /6162User-agent: MJ12bot63Disallow: /6465User-agent: DotBot66Disallow: /6768User-agent: SemrushBot69Disallow: /7071User-agent: BLEXBot72Disallow: /7374User-agent: DataForSeoBot75Disallow: /7677User-agent: MegaIndex78Disallow: /7980User-agent: PetalBot81Disallow: /8283User-agent: AspiegelBot84Disallow: /8586User-agent: SeoCheckBot87Disallow: /8889User-agent: SeoBot90Disallow: /9192User-agent: SeobilityBot93Disallow: /9495User-agent: SiteAuditBot96Disallow: /9798User-agent: Siteimprove99Disallow: /100101User-agent: SiteLockSpider102Disallow: /103104User-agent: SiteSucker105Disallow: /106107User-agent: Sogou108Disallow: /109110User-agent: spbot111Disallow: /112113User-agent: SurveyBot114Disallow: /115116User-agent: TurnitinBot117Disallow: /118119User-agent: Vagabondo120Disallow: /121122User-agent: VelenPublicWebCrawler123Disallow: /124125User-agent: WebDataStats126Disallow: /127128User-agent: WebEnhancer129Disallow: /130131User-agent: WebStripper132Disallow: /133134User-agent: WebSauger135Disallow: /136137User-agent: WebZIP138Disallow: /139140User-agent: WotBox141Disallow: /142143User-agent: Wprecon144Disallow: /145146User-agent: Xaldon_WebSpider147Disallow: /148149Sitemap: https://yoursite.com/sitemap-llm.xml`;150151 return new Response(robots, {152 status: 200,153 headers: {154 'Content-Type': 'text/plain',155 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',156 },157 });158};
Step 6: Create Sitemap-LLM.xml Endpoint
Create an LLM-optimized sitemap that includes all GEO endpoints
src/pages/sitemap-llm.xml.tstypescript🟣 Astro
1import type { APIRoute } from 'astro';23export const GET: APIRoute = () => {4 const sitemap = `<?xml version="1.0" encoding="UTF-8"?>5<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">6 <!-- Main site pages -->7 <url>8 <loc>https://yoursite.com/</loc>9 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>10 <changefreq>weekly</changefreq>11 <priority>1.0</priority>12 </url>1314 <!-- GEO Contract Endpoints -->15 <url>16 <loc>https://yoursite.com/.well-known/ai.txt</loc>17 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>18 <changefreq>monthly</changefreq>19 <priority>0.8</priority>20 </url>21 <url>22 <loc>https://yoursite.com/ai/summary.json</loc>23 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>24 <changefreq>weekly</changefreq>25 <priority>0.8</priority>26 </url>27 <url>28 <loc>https://yoursite.com/ai/faq.json</loc>29 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>30 <changefreq>monthly</changefreq>31 <priority>0.7</priority>32 </url>33 <url>34 <loc>https://yoursite.com/ai/service.json</loc>35 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>36 <changefreq>monthly</changefreq>37 <priority>0.7</priority>38 </url>3940 <!-- Other site pages -->41 <url>42 <loc>https://yoursite.com/docs</loc>43 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>44 <changefreq>weekly</changefreq>45 <priority>0.9</priority>46 </url>47</urlset>`;4849 return new Response(sitemap, {50 status: 200,51 headers: {52 'Content-Type': 'application/xml',53 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',54 },55 });56};
Next Steps
Complete your GEO implementation and test it