Skip to content

feat: add XML sitemap generation for SEO#280

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
olathedev:feat/xml-sitemap-generation
Apr 28, 2026
Merged

feat: add XML sitemap generation for SEO#280
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
olathedev:feat/xml-sitemap-generation

Conversation

@olathedev
Copy link
Copy Markdown
Contributor

@olathedev olathedev commented Apr 28, 2026

Summary

  • Add src/app/sitemap.ts using Next.js App Router's built-in sitemap API — serves /sitemap.xml automatically with ISR (revalidates every hour)
  • Add scripts/generate-sitemap.ts for standalone static sitemap generation at build time (writes public/sitemap.xml)
  • Add generate:sitemap npm script runnable via npm run generate:sitemap
  • Add NEXT_PUBLIC_SITE_URL to .env.example
  • Resolve pre-existing merge conflicts in package.json

Pages included

Route Priority Change Frequency
/ 1.0 daily
/search 0.8 weekly
/study-groups 0.7 weekly
/courses/[id] 0.8 weekly (dynamic, fetched from API)

Auth pages (/login, /signup), user-specific routes (/dashboard, /profile, /messages), and dev/demo pages are intentionally excluded.

How it works

src/app/sitemap.ts — primary approach for production. Next.js calls this at request time (or ISR interval) and renders the result as /sitemap.xml. Courses are fetched with full cursor pagination so all pages are always included.

scripts/generate-sitemap.ts — standalone fallback for CI pipelines or pre-render steps where the API is available at build time. Fails gracefully (logs a warning and includes only static routes) if the API is unreachable.

Setup

Add to .env.local:

NEXT_PUBLIC_SITE_URL=https://your-domain.com

If unset, defaults to https://teachlink.app.

Test plan

  • GET /sitemap.xml returns valid XML with all static routes
  • Course pages appear in the sitemap after the API is called
  • Removing NEXT_PUBLIC_SITE_URL falls back to the default URL without error
  • npm run generate:sitemap writes public/sitemap.xml with correct entries
  • Sitemap validates against https://www.xml-sitemaps.com/validate-xml-sitemap.html

Closes #268

- Add src/app/sitemap.ts using Next.js App Router built-in sitemap support
  - Serves /sitemap.xml automatically with ISR (revalidates every hour)
  - Includes static public routes with correct priorities and change frequencies
  - Fetches all course pages dynamically via the courses API with cursor pagination
- Add scripts/generate-sitemap.ts for standalone build-time static generation
  - Writes public/sitemap.xml; usable in CI or pre-render pipelines
  - Gracefully falls back to static routes if the API is unavailable
- Add generate:sitemap npm script (npx tsx scripts/generate-sitemap.ts)
- Add NEXT_PUBLIC_SITE_URL to .env.example
- Resolve pre-existing merge conflicts in package.json

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@olathedev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit 824a978 into rinafcode:main Apr 28, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sitemap Generation

3 participants