Shahmeer Rizwan
Contact
Back to blog
Web Development8 min read

Next.js SEO Optimization: The Complete Guide to Ranking Higher on Google

Master technical SEO with Next.js — from metadata and structured data to Core Web Vitals optimization and sitemap generation.

On this page

Next.js is one of the most SEO-friendly React frameworks available. But having a good framework is only the starting point — you still need to implement technical SEO correctly to rank on Google. This guide covers everything from metadata to structured data to performance optimization.

Dynamic Metadata with the Metadata API

Next.js 14+ provides a built-in Metadata API that generates proper meta tags for every page. This is critical for search engine crawlers and social media sharing.

app/blog/[slug]/page.tsx
1import { Metadata } from 'next';
2
3export async function generateMetadata({ params }): Promise<Metadata> {
4 const post = await getPost(params.slug);
5
6 return {
7 title: `${post.title} | Shahmeer Rizwan`,
8 description: post.excerpt,
9 openGraph: {
10 title: post.title,
11 description: post.excerpt,
12 type: 'article',
13 publishedTime: post.date,
14 authors: ['Shahmeer Rizwan'],
15 images: [{ url: post.image, width: 1200, height: 630 }],
16 },
17 twitter: {
18 card: 'summary_large_image',
19 title: post.title,
20 description: post.excerpt,
21 },
22 alternates: {
23 canonical: `https://shahmeerrizwan.com/blog/${params.slug}`,
24 },
25 };
26}

JSON-LD Structured Data

Structured data helps Google understand your content and display rich snippets in search results. Adding JSON-LD to your pages can significantly improve click-through rates.

components/JsonLd.tsx
1export function ArticleJsonLd({ post }) {
2 const jsonLd = {
3 '@context': 'https://schema.org',
4 '@type': 'Article',
5 headline: post.title,
6 description: post.excerpt,
7 datePublished: post.date,
8 author: {
9 '@type': 'Person',
10 name: 'Shahmeer Rizwan',
11 url: 'https://shahmeerrizwan.com',
12 },
13 publisher: {
14 '@type': 'Person',
15 name: 'Shahmeer Rizwan',
16 },
17 };
18
19 return (
20 <script
21 type="application/ld+json"
22 dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
23 />
24 );
25}

Automatic Sitemap Generation

Next.js allows you to generate sitemaps programmatically. This ensures search engines discover all your pages, including dynamically generated blog posts and project pages.

app/sitemap.ts
1import { MetadataRoute } from 'next';
2
3export default function sitemap(): MetadataRoute.Sitemap {
4 const baseUrl = 'https://shahmeerrizwan.com';
5 const blogs = getAllBlogSlugs();
6
7 const blogUrls = blogs.map((slug) => ({
8 url: `${baseUrl}/blog/${slug}`,
9 lastModified: new Date(),
10 changeFrequency: 'monthly' as const,
11 priority: 0.7,
12 }));
13
14 return [
15 { url: baseUrl, lastModified: new Date(), priority: 1.0 },
16 { url: `${baseUrl}/about`, lastModified: new Date(), priority: 0.8 },
17 { url: `${baseUrl}/work`, lastModified: new Date(), priority: 0.8 },
18 { url: `${baseUrl}/contact`, lastModified: new Date(), priority: 0.9 },
19 ...blogUrls,
20 ];
21}

Core Web Vitals Optimization

Core Web Vitals matter for user experience and SEO. Next.js provides practical tooling such as next/image, next/font, and route-level code splitting, but production results still depend on script budgets, cache strategy, and real-user monitoring.

  • Use next/image for automatic WebP conversion and lazy loading
  • Use next/font to eliminate font layout shift (CLS = 0)
  • Implement dynamic imports for below-the-fold components
  • Minimize third-party JavaScript and defer non-critical scripts
  • Use the Lighthouse CI to track performance on every deployment

Conclusion

SEO with Next.js is about leveraging the framework's built-in capabilities — server-side rendering, metadata API, image optimization — and combining them with structured data, sitemaps, and Core Web Vitals optimization. Implement these techniques consistently and your pages will climb the search rankings.

Shahmeer Rizwan

Full-Stack Developer

Related articles

Web Development

Why Investing in a Custom Web Application Drives Long-Term Growth

Learn how custom web applications built with modern frameworks deliver better performance, scalability, and ROI compared to template-based solutions.

E-Commerce

How to Build a Scalable E-Commerce Platform with Next.js and React

Discover why Next.js and React are the ideal stack for building high-performance, SEO-friendly e-commerce platforms that scale with your business.

ERP Systems

Why Custom ERP Systems Often Outperform Off-the-Shelf Solutions

Learn how a tailored ERP system can streamline your operations, reduce costs, and give your business a competitive edge over generic software.

Ready to invest in a custom web application?

Template-based solutions hold you back. Let's build a fast, scalable web application with modern architecture that drives SEO rankings, conversions, and long-term growth.

Free consultation · No commitment · Response within 24 hours