Skip to content

feat(seo): add sitemap.xml#119

Merged
prudentbird merged 4 commits into
devfrom
feat/seo-108-sitemap
Jun 5, 2026
Merged

feat(seo): add sitemap.xml#119
prudentbird merged 4 commits into
devfrom
feat/seo-108-sitemap

Conversation

@prudentbird

Copy link
Copy Markdown
Member

Summary

Adds a generated sitemap.xml (src/app/sitemap.ts) so search engines have a formal list of pages.

  • Lists public, indexable pages with lastModified, changeFrequency, and priority.
  • Page list is centralized in a publicRoutes constant in src/lib/site.ts — adding a public page updates the sitemap from one place.
  • Gated (/admin, /user), API, and noindex pages (auth, /terms, /privacy) are excluded.

Done when (issue #108)

  • sitemap.xml lists every public page with last-modified and priority.
  • Gated, admin, and API routes are excluded.
  • Updates automatically as new public pages are added (via the shared publicRoutes list).

Validation

  • npm run typecheck
  • npm run build ✅ — /sitemap.xml route generated.

Notes

Stacked on #107 (targets feat/seo-107-robots-txt). noindex legal/auth pages are intentionally omitted (listing non-indexable URLs in a sitemap is discouraged). robots.txt from #107 already references this sitemap.

Closes #108

Every public page now emits Open Graph and Twitter card tags (title,
description, url, image) so links render branded previews on LinkedIn,
Slack, WhatsApp and X.

- Add a branded 1200x630 social card generated with next/og, served
  site-wide via app/opengraph-image and reused for app/twitter-image.
- Add buildMetadata() helper that produces matching title/description/
  canonical plus OG and Twitter card objects for each page.
- Route home and auth pages through the helper; add OG/Twitter defaults
  to the root layout for inheritance.

Refs #106
Footer links now resolve to real pages or anchors instead of placeholders
that fell back to the homepage, and the previously missing contact and
legal pages exist.

- Footer: grouped Product/Company/Legal navigation with a real contact
  email, on-page anchors (#how-it-works, #faq), the parent company site,
  and links to the new pages.
- Add /contact (indexable) with a real, monitored address.
- Add /privacy and /terms minimal legal pages (noindex,follow).
- Add SitePage shell for consistent standalone-page layout.

Refs #112
Serve a robots.txt that allows public pages, blocks the API and gated
admin/user areas, and points crawlers to the sitemap.

Refs #107
Serve a sitemap.xml listing the public, indexable pages with last-modified,
change frequency, and priority. The page list lives in a central
publicRoutes constant so adding a public page updates the sitemap from one
place; gated, admin, and API routes are excluded.

Refs #108
@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown

Claude finished @prudentbird's task —— View job


Code Review Complete ✅

Review Checklist:

  • Read repository guidelines (CLAUDE.md)
  • Analyze sitemap.ts implementation
  • Review site.ts changes
  • Check code quality and best practices
  • Identify potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage needs
  • Provide comprehensive feedback

📋 Review Summary

Overall, this is a clean and well-structured implementation of sitemap generation for SEO purposes. The code follows Next.js 14+ conventions and demonstrates good architectural decisions.

Strengths

  1. Clean Architecture: Centralized route management in publicRoutes constant makes maintenance easier
  2. Type Safety: Proper TypeScript usage with MetadataRoute.Sitemap and satisfies for compile-time validation
  3. SEO Best Practices: Correctly excludes non-indexable pages (gated, admin, API routes)
  4. Consistent Validation: Implementation has been tested with typecheck and build commands

🔍 Code Quality & Best Practices

frontend/src/app/sitemap.ts:5-6

  • ✅ Good: Uses Next.js 14+ App Router sitemap convention
  • ✅ Good: Simple, functional approach with proper return type

frontend/src/lib/site.ts:35-49

  • ✅ Good: TypeScript satisfies operator ensures type safety while preserving literal types
  • ✅ Good: Readonly array prevents accidental mutations
  • ✅ Good: Union type for changeFrequency matches XML sitemap spec

⚠️ Potential Issues

  1. Performance Consideration: All routes share the same lastModified timestamp

    • Impact: Search engines may not efficiently crawl unchanged pages
    • Suggestion: Consider implementing per-route last modified dates based on actual content changes
  2. Missing URL Validation: absoluteUrl() function doesn't validate URL format

    • Risk: Malformed URLs could break sitemap validity
    • Suggestion: Add basic URL validation or use URL constructor for safety
// frontend/src/lib/site.ts:51-53
export function absoluteUrl(path = '/'): string {
  try {
    const url = new URL(path.startsWith('/') ? path : `/${path}`, siteConfig.url);
    return url.toString();
  } catch {
    return `${siteConfig.url}/`;
  }
}

🚨 Security Concerns

Low Risk: No significant security vulnerabilities detected

  • Environment variable usage (env.NEXT_PUBLIC_SITE_URL) is appropriate for client-side URL generation
  • No user input processing or XSS vectors identified

🧪 Test Coverage

Missing: No test files found in the codebase

  • Recommendation: Add unit tests for:
    • absoluteUrl() function with various path formats
    • Sitemap generation with different route configurations
    • Edge cases (empty routes, malformed URLs)

🚀 Performance Considerations

  1. Static Generation: ✅ Sitemap is generated at build time (optimal)
  2. Route Scale: ✅ Current implementation efficient for small-to-medium route counts
  3. Future Scaling: Consider implementing dynamic sitemap generation if routes exceed ~1000 entries

📝 Minor Suggestions

  1. Documentation: Add JSDoc comments for public functions
  2. Error Handling: Consider error boundaries for sitemap generation failures
  3. Monitoring: Add analytics/logging for sitemap generation success

🎯 Verdict

Approved with minor suggestions. This implementation correctly addresses the SEO requirements and follows Next.js best practices. The suggested improvements are non-blocking and can be addressed in future iterations.


@prudentbird prudentbird changed the base branch from feat/seo-107-robots-txt to dev June 5, 2026 19:48
@prudentbird prudentbird merged commit 54f9d09 into dev Jun 5, 2026
1 check passed
@prudentbird prudentbird deleted the feat/seo-108-sitemap branch June 5, 2026 19:52
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.

feat(seo): add sitemap.xml

1 participant