robots.txt
A /robots.txt endpoint with your sitemap's address and the paths to keep out of search.
Native .astro · no React · MIT · free, no account
Install
npx shadcn@latest add https://www.themes.dev/astro/r/robots-txt.jsonThe CLI needs a components.json (from npx shadcn init), which also writes the tokens these files use. No CLI? Copy the files below to the same paths.
Files
// /robots.txt with the sitemap's address (from @astrojs/sitemap) and the paths to keep out of search.import type { APIContext } from 'astro'; const disallow = ['/thanks/', '/404']; export function GET(context: APIContext) { const lines = ['User-agent: *', ...disallow.map((p) => `Disallow: ${p}`), '', `Sitemap: ${new URL('/sitemap-index.xml', context.site).href}`, '']; return new Response(lines.join('\n'), { headers: { 'Content-Type': 'text/plain; charset=utf-8' } });}More for site
- Theme toggleFreeA 36px button that switches light and dark and remembers the choice, plus the head script that prevents a flash.ThemeToggle.astro · ThemeScript.astro
- RSS feedFreeAn /rss.xml endpoint from a content collection with @astrojs/rss.rss.xml.ts
- llms.txtFreeAn /llms.txt endpoint that lists your pages and posts for AI tools, built from your collections.llms.txt.ts