Complete SEO Guide for Next.js
Search Engine Optimization (SEO) plays a vital role in today's web applications. A properly optimized website boosts search engine visibility, improves social media previews, and increases overall discoverability.

In this guide, we'll look at the correct way to apply SEO in Next.js, covering the following topics:
- Meta Title and Meta Description
- Canonical Tags
- Open Graph Tags (Facebook / LinkedIn)
- Twitter Cards
- JSON-LD Structured Data
- Favicons
- Handling Static vs Dynamic SEO Data
The guide uses the Next.js App Router, which offers a robust Metadata API for handling SEO.
1. Understanding SEO in Next.js
Next.js provides built-in SEO support through the Metadata API.
Rather than manually inserting <meta> tags within the <head> section, Next.js enables you to specify metadata through the metadata object or by using the generateMetadata() function.
Benefits include:
- Server-side rendering of SEO tags
- Automatic optimization
- Cleaner code structure
- Dynamic metadata support
2. Basic SEO Meta Tags in Next.js
The most important SEO tags are:
- Meta Title
- Meta Description
- Canonical URL
These can be defined in a layout.tsx or page file.
Example: Basic Metadata
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "Web Designer & Next.js Developer in Kerala | Ajith R Thampi",
description:
"Web Designer & Next.js developer from Kerala, Kochi crafting fast, scalable, and SEO-friendly websites. Specialized in React, Next.js, UI/UX, and modern web experiences.",
alternates: {
canonical: "https://ajithrthampi.com",
},
};
Explanation
title: Defines the page title shown in Google search results.
description: Provides a short summary of the page content.
canonical: Helps search engines understand the primary URL of the page to avoid duplicate content issues.
3. Open Graph Tags (For Facebook & LinkedIn)
Open Graph tags control how your website appears when shared on social media platforms such as:
Example Open Graph Configuration
export const metadata: Metadata = {
title: "Web Designer & Next.js Developer in Kerala | Ajith R Thampi",
description:
"Web Designer & Next.js developer from Kerala, Kochi crafting fast, scalable, and SEO-friendly websites.",
openGraph: {
title: "Web Designer & Next.js Developer in Kerala | Ajith R Thampi",
description:
"Web Designer & Next.js developer from Kerala, Kochi crafting fast, scalable, and SEO-friendly websites.",
url: "https://ajithrthampi.com",
siteName: "Ajith R Thampi",
images: [
{
url: "https://ajithrthampi.com/Sociallogo.png",
width: 1200,
height: 630,
alt: "Ajith R Thampi Portfolio",
},
],
locale: "en_US",
type: "website",
},
};
Recommended image size:
1200 × 630 pixels
4. Twitter Cards
Twitter uses Twitter Card metadata to generate rich previews.
Example Twitter Metadata
export const metadata: Metadata = {
twitter: {
card: "summary_large_image",
creator: "@AjithRThampi1",
title: "Web Designer & Next.js Developer in Kerala | Ajith R Thampi",
description:
"Web Designer & Next.js developer from Kerala crafting fast, scalable, SEO-friendly websites.",
images: ["https://ajithrthampi.com/Sociallogo.png"],
},
};
5. Static vs Dynamic Metadata in Next.js
Next.js supports both static metadata and dynamic metadata generation.
Static Metadata
Used when SEO data does not change.
Example:
export const metadata: Metadata = {
title: "About Ajith R Thampi",
description: "Learn more about Ajith R Thampi, a Next.js developer from Kerala.",
};
Dynamic Metadata
Used when SEO content changes based on dynamic data.
Example: Blog pages.
import { Metadata } from "next";
export async function generateMetadata({ params }): Promise<Metadata> {
const post = await getBlogPost(params.slug);
return {
title: post.title,
description: post.excerpt,
openGraph: {
title: post.title,
description: post.excerpt,
images: [post.image],
},
};
}
6. JSON-LD Structured Data
JSON-LD helps search engines better understand your content.
It can enable rich results in Google, such as:
- FAQ results
- Product listings
- Article previews
Example JSON-LD for a Website\
const jsonLd = {
"@context": "https://schema.org",
"@type": "Person",
name: "Ajith R Thampi",
url: "https://ajithrthampi.com",
jobTitle: "Web Designer & Next.js Developer",
sameAs: [
"https://x.com/AjithRThampi1",
"https://linkedin.com",
],
};
Adding JSON-LD in Next.js
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
7. Adding Favicons in Next.js
Favicons help identify your website in:
- Browser tabs
- Bookmarks
- Search results
In Next.js App Router, favicons are placed inside the app directory.
Example structure:
app ├ favicon.ico ├ icon.png ├ apple-icon.png └ layout.tsx
You can also define icons in metadata:
export const metadata = {
icons: {
icon: "/favicon.ico",
apple: "/apple-icon.png",
},
};
8. Testing SEO with Meta SEO Inspector
A useful Chrome extension for validating SEO tags is:
This tool helps verify:
- Meta tags
- Open Graph tags
- Twitter cards
- Canonical URLs
- Structured data
After deploying your website:
- Install the extension
- Open your webpage
- Click the extension icon
- Inspect the SEO metadata
It will highlight any missing or incorrect SEO tags.
Conclusion
Proper SEO implementation is essential for modern web applications.
With Next.js Metadata API, developers can easily manage:
- Meta tags
- Social media previews
- Structured data
- Canonical URLs
By implementing these SEO practices, your Next.js website becomes:
- More discoverable in search engines
- Optimized for social sharing
- Technically structured for modern SEO standards