
Implementing SEO Meta Tags in Next.js App Router
When I was building Chamjo Design, an app directory for UX inspiration, I noticed something embarrassing -- when I shared links on social media, the previews looked terrible. No description. No image. Just a sad, blank card.
This is the story of how I fixed it in version 3.0.9.
The Problem
Before this update, my meta tags were minimal:
1export const metadata = {
2title: "Chamjo | The ultimate UX inspiration hub for local apps"
3}That's it. No OpenGraph. No Twitter Card. No social preview image. When someone shared a link, they got:
- A plain title
- No description
- A generic favicon as the image
Not great for a product that's supposed to inspire good UX design.
What We Fixed
This PR touched 4 files with +45 lines and -18 lines:
- src/app/layout.tsx -- Global metadata setup
- src/app/browse/[app]/[id]/page.tsx -- Dynamic metadata
- src/app/privacy-policies/page.tsx -- Page-specific fix
- src/components/Head/Head.tsx -- Component cleanup
- Root Layout Metadata
The biggest change was in layout.tsx. Next.js App Router lets you define metadata at the root level, and it applies to all child routes.
Here's what I added:
1export const metadata: Metadata = {
2 title: "Chamjo | The ultimate UX inspiration hub for local apps and competitors",
3 description: "Ultimate UX inspiration hub for local apps and competitors",
4 icons: [
5 {
6 url: "https://...supabase.co/.../favicon.ico",
7 rel: "icon",
8 type: "image/png"
9 }
10 ],
11 openGraph: {
12 type: "website",
13 siteName: "Chamjo Design",
14 title: "Chamjo | The ultimate UX inspiration hub for local apps and competitors",
15 description: "Ultimate UX inspiration hub for local apps and competitors",
16 images: [
17 {
18 url: "https://...supabase.co/.../Banner1.webp",
19 width: 1200,
20 height: 630,
21 alt: "Chamjo Design"
22 }
23 ]
24 },
25 twitter: {
26 card: "summary",
27 site: "Chamjo Design",
28 title: "Chamjo | The ultimate UX inspiration hub for local apps and competitors",
29 description: "Ultimate UX inspiration hub for local apps and competitors",
30 images: [
31 {
32 url: "https://...supabase.co/.../Banner1.webp",
33 width: 1200,
34 height: 630,
35 alt: "Chamjo Design"
36 }
37 ]
38 }
39}Key things to note:
- icons moved from manual in the body to the metadata object
- openGraph uses the 1200x630 banner image (not the favicon)
- twitter config mirrors openGraph for consistency
- Dynamic Metadata Per Page
For dynamic routes like /browse/[app]/[id], I used generateMetadata to set page-specific titles and descriptions:
1export const generateMetadata = ({ params: { app } }: DetailAppProps) => {
2 const appCapitalized = app.charAt(0).toUpperCase() + app.slice(1)
3
4 return {
5 title: `Chamjo | ${appCapitalized}`,
6 openGraph: {
7 title: `Chamjo | ${appCapitalized}`,
8 description: "Ultimate UX inspiration hub for local apps and competitors"
9 }
10 }
11}This way, every app page has a unique title while inheriting the global description and images from the root layout.
- Image Optimization for Social
The biggest visual change was switching from a tiny favicon to a proper OG banner image:
Before: favicon.ico (32x32) After: Banner1.webp (1200x630)
Why 1200x630? That's the recommended size for OpenGraph images. Twitter Cards also work best with this aspect ratio.
I hosted the image on Supabase storage, but you could use any CDN or even put it in your /public folder.
- Component Cleanup
I also cleaned up the Head component. Before, I had manual tags scattered across files. Now, the metadata API handles everything.
Before:
1<meta name='og:image' property='og:image' content={iconUrl} />
2<meta name='twitter:image' property='twitter:image' content={iconUrl} />After:
All handled by the metadata export in layout.tsx. Much cleaner.
Results
After deploying v3.0.9:
- Social share previews now show the Chamjo banner
- Twitter cards display correctly with image and description
- Consistent branding across LinkedIn, Facebook, Twitter/X
- Cleaner codebase -- no scattered meta tags
Lessons Learned
- Next.js App Router has built-in SEO support that's genuinely useful. Use it instead of manual meta tags.
- generateMetadata is powerful for dynamic routes. Don't skip it.
- Image dimensions matter. 1200x630 is the sweet spot for OG images.
- Test your social previews:
Final Thoughts
This was a small PR -- just 63 lines changed. But the impact on how Chamjo appears when shared on social media was huge.
If your app's social previews still look sad, take 30 minutes to implement proper meta tags. Your users (and your brand) will thank you.
References
- Next.js Metadata API: https://nextjs.org/docs/app/api-reference/functions/generate-metadata
- OpenGraph Protocol: https://ogp.me/
- Twitter Card Validator: https://cards-dev.twitter.com/validator
- PR #2: https://github.com/nicogulo/chamjo-app/pull/2
Subscribe to Newsletter
Get the latest posts delivered straight to your inbox.
