-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add title and meta description to layout for improved SEO #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds SEO metadata—page title and meta description—to the RootLayout component's head section. No changes to runtime logic or rendering flow; purely static metadata enhancement. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/layout.tsx (1)
24-24: Hardcoded structured data misrepresents non-home pages.The structured data is hardcoded to
'home', but this root layout applies to all routes. Pages like/dashboard,/events, or/profilewill incorrectly advertise themselves as the home page in their structured data, which can confuse search engines and harm SEO.Solution: Move structured data generation to page-specific Server Components, similar to the metadata recommendation above:
// app/page.tsx export const metadata = { /* ... */ } // Add structured data per page const structuredData = getPageStructuredData('home') // Then inject in page component or use Next.js metadata API if it supports JSON-LDOr if you need it in layout, derive the page type from
pathname:const pageType = pathname === '/' ? 'home' : pathname.split('/')[1] || 'home' const structuredData = getPageStructuredData(pageType)However, per-page Server Components with metadata exports is the cleaner, more maintainable approach.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/layout.tsx(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test Suite
| <title>Codeunia | Bridge the gap between campus and career</title> | ||
| <meta name="description" content="Codeunia is a community platform connecting students with hackathons, events, internships, and career opportunities. Bridge the gap between campus and career." /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Hardcoded metadata in root layout affects ALL pages.
The title and meta description are static in the root layout, which means every page in the app (dashboard, profile, events, etc.) will have identical metadata. This is detrimental to SEO because:
- Search engines penalize duplicate titles/descriptions across pages
- Each page should have unique, contextual metadata
- Browser tabs cannot distinguish between pages
- The pathname-specific content won't be reflected in search results
Recommended approach:
In Next.js 15 App Router, metadata should be defined per page/layout using the metadata export or generateMetadata function in Server Components. Since this root layout needs to be a Client Component (for usePathname()), consider:
- Remove these tags from root layout and define metadata in each page's Server Component:
// app/page.tsx (home page)
export const metadata = {
title: 'Codeunia | Bridge the gap between campus and career',
description: 'Codeunia is a community platform connecting students...'
}-
Or use a hybrid approach: Keep root layout as Server Component and move pathname-dependent logic elsewhere, or use template/layout files per route segment.
-
Per-page metadata examples:
/dashboard→ "Dashboard | Codeunia"/events→ "Upcoming Events | Codeunia"/profile→ "Your Profile | Codeunia"
This ensures each route has unique, SEO-optimized metadata.
🤖 Prompt for AI Agents
In app/layout.tsx around lines 30-31 the root layout currently contains
hardcoded <title> and <meta description> which forces identical metadata across
all pages; remove these tags from the root layout and instead define metadata
per route using Next.js App Router (export const metadata or export async
function generateMetadata in each page or layout server component) — if you need
pathname-dependent logic, either convert the root to a Server Component and move
client-only usePathname() into a child Client Component, or create per-segment
layout/template files so each route can export its own metadata (e.g.,
dashboard, events, profile) to ensure unique, SEO-friendly titles and
descriptions.
add title and meta description to layout for improved SEO
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.