From 7f1f7b614b1e96a9210af5960461fd12086abf66 Mon Sep 17 00:00:00 2001 From: Alex Verkhovsky Date: Thu, 5 Feb 2026 15:47:19 -0700 Subject: [PATCH] fix: generate robots.txt dynamically from site base URL Replace static robots.txt with an Astro endpoint that uses the configured site URL, so sitemap references are correct on both fork deployments and production. --- .../robots.txt => src/pages/robots.txt.ts} | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename website/{public/robots.txt => src/pages/robots.txt.ts} (61%) diff --git a/website/public/robots.txt b/website/src/pages/robots.txt.ts similarity index 61% rename from website/public/robots.txt rename to website/src/pages/robots.txt.ts index b437f516e..d4dec7971 100644 --- a/website/public/robots.txt +++ b/website/src/pages/robots.txt.ts @@ -1,5 +1,10 @@ -# BMAD Method Documentation -# https://docs.bmad-method.org/ +import type { APIRoute } from 'astro'; + +export const GET: APIRoute = ({ site }) => { + const siteUrl = site?.href.replace(/\/$/, '') ?? ''; + + const body = `# BMAD Method Documentation +# ${siteUrl}/ # # This file controls web crawler access to the documentation site. @@ -34,4 +39,10 @@ User-agent: cohere-ai Allow: / # Sitemap -Sitemap: https://docs.bmad-method.org/sitemap-index.xml +Sitemap: ${siteUrl}/sitemap-index.xml +`; + + return new Response(body, { + headers: { 'Content-Type': 'text/plain; charset=utf-8' }, + }); +};