feat: add XML sitemap generation for SEO#280
Merged
RUKAYAT-CODER merged 1 commit intoApr 28, 2026
Merged
Conversation
- 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>
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/app/sitemap.tsusing Next.js App Router's built-in sitemap API — serves/sitemap.xmlautomatically with ISR (revalidates every hour)scripts/generate-sitemap.tsfor standalone static sitemap generation at build time (writespublic/sitemap.xml)generate:sitemapnpm script runnable vianpm run generate:sitemapNEXT_PUBLIC_SITE_URLto.env.examplepackage.jsonPages included
//search/study-groups/courses/[id]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:If unset, defaults to
https://teachlink.app.Test plan
GET /sitemap.xmlreturns valid XML with all static routesNEXT_PUBLIC_SITE_URLfalls back to the default URL without errornpm run generate:sitemapwritespublic/sitemap.xmlwith correct entriesCloses #268