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';
2
3export const GET: APIRoute = () => {
4 const aiTxt = `# AI.txt for yoursite.com
5# This file specifies which JSON endpoints are accessible to AI crawlers
6
7User-agent: *
8Allow: /ai/faq.json
9Allow: /ai/service.json
10Allow: /ai/summary.json
11
12# Last updated: ${new Date().toISOString().split('T')[0]}`;
13
14 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';
2
3export 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 };
27
28 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';
2
3export 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 };
22
23 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';
2
3export 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 };
33
34 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';
2
3export const GET: APIRoute = () => {
4 const robots = `# Allow legitimate search engines and AI crawlers
5User-agent: Googlebot
6Allow: /
7
8User-agent: Bingbot
9Allow: /
10
11User-agent: Slurp
12Allow: /
13
14User-agent: DuckDuckBot
15Allow: /
16
17User-agent: Baiduspider
18Allow: /
19
20User-agent: YandexBot
21Allow: /
22
23# Allow AI crawlers for GEO content
24User-agent: GPTBot
25Allow: /
26
27User-agent: ChatGPT-User
28Allow: /
29
30User-agent: CCBot
31Allow: /
32
33User-agent: anthropic-ai
34Allow: /
35
36User-agent: Claude-Web
37Allow: /
38
39# Allow social media crawlers
40User-agent: facebookexternalhit
41Allow: /
42
43User-agent: Twitterbot
44Allow: /
45
46User-agent: LinkedInBot
47Allow: /
48
49# Block suspicious bots and scrapers
50User-agent: *
51Disallow: /api/
52Disallow: /_astro/
53Disallow: /admin/
54Disallow: /private/
55Disallow: /*.json$
56Disallow: /*?*
57
58# Block common bad bots
59User-agent: AhrefsBot
60Disallow: /
61
62User-agent: MJ12bot
63Disallow: /
64
65User-agent: DotBot
66Disallow: /
67
68User-agent: SemrushBot
69Disallow: /
70
71User-agent: BLEXBot
72Disallow: /
73
74User-agent: DataForSeoBot
75Disallow: /
76
77User-agent: MegaIndex
78Disallow: /
79
80User-agent: PetalBot
81Disallow: /
82
83User-agent: AspiegelBot
84Disallow: /
85
86User-agent: SeoCheckBot
87Disallow: /
88
89User-agent: SeoBot
90Disallow: /
91
92User-agent: SeobilityBot
93Disallow: /
94
95User-agent: SiteAuditBot
96Disallow: /
97
98User-agent: Siteimprove
99Disallow: /
100
101User-agent: SiteLockSpider
102Disallow: /
103
104User-agent: SiteSucker
105Disallow: /
106
107User-agent: Sogou
108Disallow: /
109
110User-agent: spbot
111Disallow: /
112
113User-agent: SurveyBot
114Disallow: /
115
116User-agent: TurnitinBot
117Disallow: /
118
119User-agent: Vagabondo
120Disallow: /
121
122User-agent: VelenPublicWebCrawler
123Disallow: /
124
125User-agent: WebDataStats
126Disallow: /
127
128User-agent: WebEnhancer
129Disallow: /
130
131User-agent: WebStripper
132Disallow: /
133
134User-agent: WebSauger
135Disallow: /
136
137User-agent: WebZIP
138Disallow: /
139
140User-agent: WotBox
141Disallow: /
142
143User-agent: Wprecon
144Disallow: /
145
146User-agent: Xaldon_WebSpider
147Disallow: /
148
149Sitemap: https://yoursite.com/sitemap-llm.xml`;
150
151 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';
2
3export 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>
13
14 <!-- 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>
39
40 <!-- 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>`;
48
49 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};