Skip to content

Commit 62a2fd1

Browse files
bchapuisclaude
andcommitted
Add robots.txt SSR route and sitemap link tag for SEO discovery
The static public/robots.txt wasn't being served because all requests route through the Worker → React Router pipeline. Adding an explicit SSR route (matching the existing sitemap.xml pattern) ensures robots.txt is always served. Also adds a <link rel="sitemap"> tag as a secondary discovery path for crawlers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 66f0195 commit 62a2fd1

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

apps/www/src/root.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const links = () => [
1313
{ rel: "preload", href: stylesheet, as: "style" },
1414
{ rel: "stylesheet", href: stylesheet },
1515
{ rel: "icon", href: "/icon.svg", type: "image/svg+xml" },
16+
{ rel: "sitemap", type: "application/xml", href: "/sitemap.xml" },
1617
];
1718

1819
export function Layout({ children }: { children: React.ReactNode }) {

apps/www/src/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default [
55
route("terms", "routes/terms.tsx"),
66
route("privacy", "routes/privacy.tsx"),
77
route("cookies", "routes/cookies.tsx"),
8+
route("robots.txt", "routes/robots[.]txt.tsx"),
89
route("sitemap.xml", "routes/sitemap[.]xml.tsx"),
910
route("nodes", "routes/nodes/index.tsx"),
1011
route("nodes/:category", "routes/nodes/$category.tsx"),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const websiteUrl = import.meta.env.VITE_WEBSITE_URL;
2+
3+
export function loader() {
4+
const body = `User-agent: *
5+
Allow: /
6+
7+
Sitemap: ${websiteUrl}/sitemap.xml
8+
`;
9+
10+
return new Response(body, {
11+
headers: {
12+
"Content-Type": "text/plain",
13+
"Cache-Control": "public, max-age=86400",
14+
},
15+
});
16+
}

0 commit comments

Comments
 (0)