Next.js 15 Meta Tags Complete Guide — og:image to hreflang
Next.js 15 App Router lets you manage static and dynamic meta tags declaratively via the Metadata API. Use generateMetadata() to auto-generate per-page og:image, title, and description at build or request time.
Next.js 15 Meta Tags Complete Guide — og:image to hreflang
Key Summary Next.js 15 App Router uses the Metadata API to generate SEO-critical meta tags. This guide covers: generateMetadata() for dynamic pages, static metadata for layout files, og:image with Next.js Image Optimization, hreflang for multilingual sites, canonical URLs, and Twitter Card configuration.
Basic Static Metadata (layout.tsx)
import type { Metadata } from "next";
export const metadata: Metadata = {
title: {
template: "%s | MillionsCode",
default: "MillionsCode — Free Tools & Finance Info",
},
description: "Free financial calculators, crypto tools, and investment guides.",
metadataBase: new URL("https://millionscode.com"),
openGraph: {
type: "website",
siteName: "MillionsCode",
locale: "ko_KR",
},
twitter: {
card: "summary_large_image",
site: "@millionscode",
},
};Dynamic Metadata for Blog Posts
// app/blog/[id]/page.tsx
import type { Metadata } from "next";
export async function generateMetadata(
{ params }: { params: Promise<{ id: string }> }
): Promise<Metadata> {
const { id } = await params;
const post = await getPost(id);
return {
title: post.title,
description: post.description,
openGraph: {
title: post.title,
description: post.description,
type: "article",
publishedTime: post.published_at,
images: [{
url: `/api/og?title=${encodeURIComponent(post.title)}`,
width: 1200,
height: 628,
alt: post.title,
}],
},
alternates: {
canonical: `https://millionscode.com/blog/${id}`,
languages: {
"en": `https://millionscode.com/en/blog/${id}`,
"ja": `https://millionscode.com/ja/blog/${id}`,
"zh": `https://millionscode.com/zh/blog/${id}`,
"x-default": `https://millionscode.com/blog/${id}`,
},
},
};
}hreflang for Multilingual Sites
The alternates.languages field in Next.js 15 automatically generates tags. Always include x-default pointing to the primary language version.
og:image with Dynamic Generation
// app/api/og/route.tsx
import { ImageResponse } from "next/og";
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const title = searchParams.get("title") ?? "MillionsCode";
return new ImageResponse(
(<div style={{ display: "flex", width: 1200, height: 628,
background: "#1a1a2e", alignItems: "center", padding: 80 }}>
<h1 style={{ color: "white", fontSize: 56, fontWeight: 700 }}>{title}</h1>
</div>),
{ width: 1200, height: 628 }
);
}💡 Test your meta tags live with our Meta Tag Checker tool.
🔧 Related Free Tools
Related Products (Next.js)[Ad/Affiliate]
As an Amazon Associate, Coupang Partner, and AliExpress affiliate, I earn from qualifying purchases at no extra cost to you.
Related Posts
2026년 가장 인기 있는 AI 코딩 도구 Claude Code, Cursor, GitHub Copilot 3종을 월 가격·1M 컨텍스트·한국어...
IT블로그 SEO 2026 — 구글 알고리즘 변화와 대응 전략2026년 블로그 SEO 완벽 가이드. 구글 E-E-A-T·AI Overview·코어 업데이트 대응 전략. 롱테일 키워드·FAQ 구조·테크니컬 ...
IT2026 NordVPN vs ExpressVPN vs Surfshark — VPN 속도·가격·보안 비교2026년 기준 NordVPN, ExpressVPN, Surfshark 3대 VPN의 속도, 가격, 서버 수, 노로그 정책, 스트리밍 지원을 비...
IT2026 맥북 에어 M4 vs 삼성 갤럭시북4 vs 레노버 요가 — 개발자 노트북 비교2026년 기준 맥북 에어 M4, 삼성 갤럭시북4 프로, 레노버 요가 슬림 7i의 CPU, 배터리, 디스플레이, 개발 워크플로우를 비교합니다....