Key Engineering Takeaways
- Enable trailingSlash: true alongside explicit per-route canonical URLs so CDNs never serve duplicate trailing vs non-trailing versions.
- Scope root layout JSON-LD to WebSite + Person, and emit page-specific ProfilePage, Blog, CollectionPage, or TechArticle per route.
- Keep content-heavy pages as pure Server Components and push canvases, filters, and search overlays into compact Client Component islands.
- Inline critical CSS (experimental.inlineCss: true) and defer below-the-fold images so First Contentful Paint requires zero blocking stylesheets.
1. Keep Content-Rich Pages as Zero-JS Server Components
The single biggest SEO and bundle-size mistake in Next.js App Router projects is stamping 'use client' on top-level page components or article views. When a page primarily renders semantic headings, paragraphs, code blocks, structured FAQs, and internal navigation links, keeping it as a Server Component ships clean HTML to browsers and Googlebot without hydrating kilobytes of static prose inside JavaScript chunks.
In my own portfolio architecture, interactive components — such as the 3D hero canvas, link filters, terminal overlay, and backend traffic sandbox — live cleanly inside isolated Client Components, while documentation pages, project schemas, and blog article routes stay purely Server-rendered at build time.
With output: 'export' enabled, Next.js compiles every static route and every dynamic slug from generateStaticParams() into self-contained HTML files ready to run on Cloudflare Pages, Netlify, S3/CloudFront, or Nginx with zero Node.js cold-start latency.
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "export",
trailingSlash: true,
images: { unoptimized: true },
experimental: {
inlineCss: true,
},
};
export default nextConfig;2. Clean Canonical Hygiene & Page-Scoped Schema.org @graph
Modern Google Search relies heavily on unambiguous entity linking rather than repetitive meta keyword stuffing. Instead of pasting redundant or conflicting schema blocks onto every page, define your authoritative #website and #person entities once inside root layout.tsx with stable @id IRIs, then connect route-specific entities back to those IDs.
For example, an About page emits AboutPage + BreadcrumbList pointing to #person; a Projects page emits CollectionPage + SoftwareSourceCode items; an article emits TechArticle + FAQPage + BreadcrumbList; and a Contact page pairs ContactPage with FAQPage. Scoping ProfilePage exclusively to the home route avoids confusing crawlers with conflicting page types on subpages.
- Keep rendered <title> strings under 60 characters (accounting for titleTemplate suffixes) so desktop and mobile SERPs never truncate.
- Write unique 135–160 character meta descriptions tailored to search intent on every route.
- Export dynamic app/sitemap.ts and app/robots.ts (and generate a clean /llms.txt index) while removing legacy static files in public/ so outputs never drift.
3. Eliminating Render-Blocking Requests & Optimising Image Priority
On simulated 4G mobile throttles used by PageSpeed Insights and Lighthouse, even two external 15 KB CSS stylesheets introduce an entire extra TLS/HTTP round-trip before First Contentful Paint (FCP). Enabling experimental.inlineCss in Next.js 16 inlines compiled CSS directly into the initial HTML payload alongside self-hosted next/font/google variable WOFF2 subsets (zero external fonts.googleapis.com waterfalls).
Equally important for LCP and preload discipline: only mark an image with fetchPriority='high' when it sits above the fold on that specific route. On a landing page led by a hero section, preloading a portrait located two viewports below the fold competes directly with web fonts for initial bandwidth — make priority prop-driven so subpages like /about/ preload it immediately while Home loads it lazily.
export function buildPageMetadata({
title,
description,
path,
type = "website",
publishedTime,
modifiedTime,
}: PageSeoOptions): Metadata {
const canonicalUrl = `https://debajyotidutta.com${path}`;
return {
title,
description,
alternates: { canonical: canonicalUrl },
openGraph: {
title: `${title} | Debajyoti Dutta`,
description,
url: canonicalUrl,
type,
...(type === "article" ? { publishedTime, modifiedTime, authors: ["Debajyoti Dutta"] } : {}),
},
};
}4. Hash Navigation, Cache Headers & Browserlist Targets
Technical SEO and Core Web Vitals also depend on small platform details: pairing data-scroll-behavior='smooth' on <html> with instant scroll reset on pathname transitions (never applying overflow-x: hidden to both html and body, which breaks sticky elements and scroll resets), setting scroll-margin-top on anchored sections, and shipping modern ES targets in package.json browserslist to trim legacy polyfills.
Finally, configure immutable 1-year Cache-Control headers on /_next/static/* and /images/* alongside security headers (X-Content-Type-Options, Referrer-Policy, X-Frame-Options) in public/_headers so static CDN edges earn top scores across Performance, Best Practices, Accessibility, and SEO.
Frequently Asked Questions
Does output: 'export' hurt Next.js SEO compared to Node SSR?
No. Static HTML files pre-render full semantic markup, meta tags, canonicals, and JSON-LD at build time, giving search crawlers even faster Time to First Byte (TTFB) at CDN edge nodes than dynamic SSR without server cold starts.
Why use trailingSlash: true on static Next.js sites?
Static hosts and CDNs naturally serve folder index files (/about/index.html) at /about/. Setting trailingSlash: true aligns Next.js <Link> navigation, canonical links, and sitemap.xml so bots never waste crawl budget on trailing-slash 301 hops.
Does experimental.inlineCss work safely in production?
For portfolios, blogs, and multi-page marketing/editorial sites with ~30–50 KB CSS payloads, inlineCss removes render-blocking stylesheet requests and significantly boosts mobile FCP/LCP while keeping cached repeat navigation fast.