Add robots.txt and sitemap.xml.gz for SEO

Adds a static robots.txt blocking admin/API/auth routes, a sitemap
generation script (scripts/generate-sitemap.mjs) that writes both
sitemap.xml and sitemap.xml.gz to public/, and hooks it into the
build so the sitemap is always fresh on deploy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-05-24 22:05:37 -07:00
parent 874a2db853
commit 2978ba787d
5 changed files with 91 additions and 1 deletions

View file

@ -3,8 +3,9 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "npm run build:remix && npm run build:server", "build": "npm run sitemap && npm run build:remix && npm run build:server",
"build:remix": "react-router build", "build:remix": "react-router build",
"sitemap": "node scripts/generate-sitemap.mjs",
"build:server": "node scripts/build-server.mjs", "build:server": "node scripts/build-server.mjs",
"db:generate": "dotenv -- drizzle-kit generate", "db:generate": "dotenv -- drizzle-kit generate",
"db:migrate": "dotenv -- drizzle-kit migrate", "db:migrate": "dotenv -- drizzle-kit migrate",

10
public/robots.txt Normal file
View file

@ -0,0 +1,10 @@
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /api/
Disallow: /onboarding
Disallow: /settings
Disallow: /user-profile
Sitemap: https://brackt.com/sitemap.xml.gz

39
public/sitemap.xml Normal file
View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://brackt.com/</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://brackt.com/how-to-play</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://brackt.com/rules</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://brackt.com/sports</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://brackt.com/support</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://brackt.com/privacy-policy</loc>
<lastmod>2026-05-25</lastmod>
<changefreq>yearly</changefreq>
<priority>0.4</priority>
</url>
</urlset>

BIN
public/sitemap.xml.gz Normal file

Binary file not shown.

View file

@ -0,0 +1,40 @@
import { gzipSync } from "zlib";
import { writeFileSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const publicDir = join(__dirname, "..", "public");
const BASE_URL = "https://brackt.com";
const urls = [
{ loc: "/", changefreq: "weekly", priority: "1.0" },
{ loc: "/how-to-play", changefreq: "monthly", priority: "0.8" },
{ loc: "/rules", changefreq: "monthly", priority: "0.8" },
{ loc: "/sports", changefreq: "weekly", priority: "0.8" },
{ loc: "/support", changefreq: "monthly", priority: "0.6" },
{ loc: "/privacy-policy", changefreq: "yearly", priority: "0.4" },
];
const today = new Date().toISOString().split("T")[0];
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls
.map(
({ loc, changefreq, priority }) => ` <url>
<loc>${BASE_URL}${loc}</loc>
<lastmod>${today}</lastmod>
<changefreq>${changefreq}</changefreq>
<priority>${priority}</priority>
</url>`
)
.join("\n")}
</urlset>
`;
writeFileSync(join(publicDir, "sitemap.xml"), xml);
writeFileSync(join(publicDir, "sitemap.xml.gz"), gzipSync(xml));
console.log(`Sitemap generated: ${urls.length} URLs`);