Files
skills/public/frontend-nextjs-seo.html
zeekayandHanzo Dev 9e10c1c10e Each llms index points at the other two
hanzoskills.com/llms.txt now opens with the install line, the API
reference index and the company index, so an agent that lands on any
one of the three can find the rest.

robots.txt claimed 537 documents while llms.txt counts 920. The number
is gone from robots.txt; llms.txt derives it.

public/ is regenerated from scripts/site.py, which it had fallen
behind: the copy-prompt menu and agent bar were in the generator and
not in the committed pages. tests/site.mjs passes against the result.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 00:27:59 -07:00

798 lines
34 KiB
HTML

<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>frontend-nextjs-seo</title>
<meta name="color-scheme" content="dark">
<style>
/* Committed to one visual world: a dark instrument panel. No light variant —
the dot field and the hairline rules only read on black, and a naive
inversion would wash both out. Every colour is painted explicitly so the page
never borrows a host background. */
@font-face{font-family:'Zen';src:url('/fonts/Zen-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen';src:url('/fonts/Zen-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Pixel Square';src:url('/fonts/ZenPixel-Square.woff2') format('woff2');font-style:normal;font-display:swap}
:root{
--ink:#f4f4f2; --soft:#9c9c98; --faint:#6a6a66; --ground:#000; --panel:#0a0a0a;
--line:#232323; --line-hi:#3a3a3a; --accent:#f4f4f2;
--font-zen-sans:'Zen',-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
--font-zen-mono:'Zen Mono',ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
--font-zen-pixel-square:'Zen Pixel Square',monospace;
--mono:var(--font-zen-mono);
--sans:var(--font-zen-sans);
/* Controls are pills and surfaces are soft, as on hanzo.ai. */
--r:999px; --r-soft:14px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--sans);
font-size:16px;line-height:1.65;-webkit-font-smoothing:antialiased}
.wrap{max-width:60rem;margin:0 auto;padding:0 1.75rem}
/* The dot field. A halftone made of one repeating radial-gradient, faded out
along the diagonal by a mask so it reads as a wave rather than wallpaper. */
/* No overflow clip here: the dot field is inset to the box already, and a clip
would cut off the copy-prompt menu. */
.hero{position:relative;border-bottom:1px solid var(--line)}
.hero::before{content:"";position:absolute;inset:0;
background-image:radial-gradient(var(--line-hi) 1px, transparent 1px);
background-size:7px 7px;
-webkit-mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
pointer-events:none}
.hero .wrap{position:relative;padding-top:5.5rem;padding-bottom:4rem}
nav{border-bottom:1px solid var(--line)}
nav .in{max-width:60rem;margin:0 auto;padding:1.1rem 1.75rem;display:flex;
justify-content:space-between;align-items:center;gap:1rem}
.brand{font-family:var(--mono);font-size:.85rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--ink);text-decoration:none;
display:inline-flex;align-items:center;gap:.6rem}
.brand i{font-style:normal;color:var(--faint)}
.mark{width:1.15em;height:1.15em;display:block;flex:0 0 auto}
nav a.up{font-family:var(--mono);font-size:.72rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--soft);text-decoration:none}
nav a.up:hover{color:var(--ink)}
h1{font-family:var(--mono);font-size:clamp(2rem,5.4vw,3.4rem);line-height:1.12;
letter-spacing:-.02em;margin:0 0 1.1rem;font-weight:500;text-wrap:balance}
h1 em{font-style:normal;color:var(--faint)}
.lede{color:var(--soft);font-size:1.05rem;max-width:52ch;margin:0 0 2.25rem}
.btns{display:flex;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem;align-items:center}
.btn{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--mono);
font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;
padding:.8rem 1.4rem;border:1px solid var(--line-hi);border-radius:var(--r);
color:var(--ink);text-decoration:none;background:transparent;cursor:pointer;
line-height:1.2;font-weight:400}
.btn:hover{background:#141414;text-decoration:none;border-color:var(--soft)}
.btn.solid{background:var(--ink);color:#000;border-color:var(--ink)}
.btn.solid:hover{background:#d8d8d4}
.btn .chev{width:.7em;height:.7em;flex:0 0 auto;transition:transform .15s ease}
.btn[aria-expanded="true"] .chev{transform:rotate(180deg)}
/* Copy-prompt selector. Each row copies the prompt for its own target. */
.copy{position:relative;display:inline-flex}
.menu{position:absolute;top:calc(100% + .5rem);left:0;z-index:20;min-width:21rem;
background:var(--panel);border:1px solid var(--line-hi);border-radius:var(--r-soft);
padding:.4rem;display:flex;flex-direction:column;
box-shadow:0 12px 32px rgba(0,0,0,.75)}
.menu[hidden]{display:none}
.mi{display:flex;align-items:center;gap:.7rem;width:100%;text-align:left;
padding:.62rem .8rem;border:0;border-radius:calc(var(--r-soft) - .35rem);
background:transparent;color:var(--ink);font-family:var(--mono);font-size:.76rem;
letter-spacing:.04em;text-decoration:none;cursor:pointer;line-height:1.3;
white-space:nowrap}
.mi:hover,.mi:focus-visible{background:#181818;outline:none}
.mi .mark{width:1.05rem;height:1.05rem;color:var(--soft)}
.mi:hover .mark{color:var(--ink)}
.mi u{margin-left:auto;color:var(--faint);text-decoration:none;font-size:.68rem;
letter-spacing:.1em;text-transform:uppercase}
/* Works-with bar: one scrolling row, name and mark per agent. */
.strip{border-bottom:1px solid var(--line);background:var(--panel)}
.strip .in{max-width:60rem;margin:0 auto;padding:.9rem 1.75rem;display:flex;
align-items:center;gap:1.25rem;font-family:var(--mono);font-size:.72rem;
letter-spacing:.1em;text-transform:uppercase;color:var(--faint)}
.strip b{color:var(--soft);font-weight:400;flex:0 0 auto;
border-right:1px solid var(--line);padding-right:1.25rem;align-self:stretch;
display:flex;align-items:center}
.bar{display:flex;align-items:center;gap:.5rem;flex:1 1 auto;min-width:0;
overflow-x:auto;scrollbar-width:none;scroll-snap-type:x proximity;
-webkit-overflow-scrolling:touch;
-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent);
mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent)}
.bar::-webkit-scrollbar{display:none}
.agent{display:inline-flex;align-items:center;gap:.45rem;flex:0 0 auto;
padding:.4rem .85rem;border:1px solid var(--line);border-radius:var(--r);
color:var(--soft);white-space:nowrap;scroll-snap-align:start;
text-decoration:none;background:var(--ground)}
.agent:hover{color:var(--ink);border-color:var(--line-hi);text-decoration:none}
.agent .mark{width:.95rem;height:.95rem}
h2{font-family:var(--mono);font-size:1.1rem;letter-spacing:-.01em;margin:2.75rem 0 .75rem;font-weight:500}
h3{font-size:1rem;margin:2rem 0 .5rem;font-weight:600}
h4,h5,h6{font-size:.94rem;margin:1.5rem 0 .5rem;font-weight:600}
p{margin:0 0 1rem;max-width:70ch}
ul,ol{margin:0 0 1rem;padding-left:1.35rem;max-width:70ch}
li{margin:.22rem 0}
a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;
text-decoration-color:var(--line-hi)}
a:hover{text-decoration-color:var(--ink)}
a:focus-visible{outline:1px solid var(--ink);outline-offset:3px}
code{font-family:var(--mono);font-size:.85em;background:var(--panel);
border:1px solid var(--line);border-radius:5px;padding:.1em .36em}
pre{background:var(--panel);border:1px solid var(--line);padding:1rem 1.1rem;
border-radius:var(--r-soft);overflow-x:auto;margin:0 0 1.25rem}
pre code{background:none;border:0;padding:0;font-size:.82rem;line-height:1.7}
blockquote{margin:0 0 1rem;padding-left:1rem;border-left:1px solid var(--line-hi);color:var(--soft)}
hr{border:0;border-top:1px solid var(--line);margin:2.5rem 0}
table{border-collapse:collapse;width:100%;margin:0 0 1.25rem;font-size:.92rem;
display:block;overflow-x:auto}
th,td{border:1px solid var(--line);padding:.5rem .7rem;text-align:left}
.curl{display:block;background:var(--panel);border:1px solid var(--line);
border-radius:var(--r-soft);padding:.95rem 1.1rem;font-family:var(--mono);
font-size:.8rem;color:var(--soft);overflow-x:auto;margin:0 0 2.5rem;
white-space:pre;line-height:1.9}
.curl b{color:var(--ink);font-weight:400}
.curl i{font-style:normal;color:var(--faint)}
/* index */
#q{width:100%;padding:.85rem 1.2rem;font-family:var(--mono);font-size:.85rem;color:var(--ink);
background:var(--panel);border:1px solid var(--line);border-radius:var(--r);margin:0 0 .6rem}
#q::placeholder{color:var(--faint);text-transform:uppercase;letter-spacing:.1em;font-size:.72rem}
#q:focus{outline:none;border-color:var(--soft)}
#count{color:var(--faint);font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;
text-transform:uppercase;margin:0 0 2rem}
.cat{margin:2.5rem 0 .5rem;font-family:var(--mono);font-size:.7rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);border-bottom:1px solid var(--line);
padding-bottom:.45rem}
.row{display:block;padding:.6rem .9rem;margin:0 -.9rem;border-bottom:1px solid var(--line);
border-radius:var(--r-soft);text-decoration:none}
.row:hover{background:#0a0a0a}
.nm{font-family:var(--mono);font-size:.84rem;color:var(--ink);display:block}
.ds{color:var(--soft);font-size:.9rem;display:block;margin-top:.12rem}
footer{margin-top:4rem;padding:2rem 0 4rem;border-top:1px solid var(--line);
color:var(--faint);font-size:.85rem}
footer a{color:var(--soft)}
.fmap{display:grid;gap:1.75rem;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));
margin:0 0 2rem;font-size:.85rem}
.fmap b{display:block;font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);font-weight:400;margin:0 0 .6rem;
border-bottom:1px solid var(--line);padding-bottom:.4rem}
.fmap a{display:inline-block;color:var(--ink);text-decoration:none;margin:.3rem .35rem 0 0}
.fmap a:hover{text-decoration:underline}
.fmap div{color:var(--faint);line-height:1.5}
.fend{border-top:1px solid var(--line);padding-top:1.25rem;font-size:.82rem}
@media (max-width:640px){
.hero .wrap{padding-top:3.25rem;padding-bottom:2.75rem}
.btns{gap:.5rem}
.btn{padding:.75rem 1.15rem;font-size:.68rem}
.copy,.copy .btn{width:100%;justify-content:center}
.menu{left:0;right:0;min-width:0}
.strip .in{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem 1.75rem}
.strip b{border-right:0;padding-right:0}
.bar{width:100%}
}
</style>
<link rel="alternate" type="text/markdown" href="/frontend-nextjs-seo.md">
<link rel="icon" href="/favicon.svg">
<link rel="canonical" href="https://hanzoskills.com/frontend-nextjs-seo">
</head>
<!-- Reading this with a machine? Every page here is also plain markdown.
This one: https://hanzoskills.com/frontend-nextjs-seo.md
Index: https://hanzoskills.com/llms.txt
Corpus: https://hanzoskills.com/all.md
Append .md to any path for the markdown twin. -->
<body>
<nav><div class="in">
<a class="brand" href="/"><svg class="mark" viewBox="0 0 67 67" fill="currentColor" aria-hidden="true"><path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/></svg> HANZO<i>SKILLS</i></a>
<a class="up" href="/">All skills</a>
</div></nav>
<div class="wrap">
<h1>frontend-nextjs-seo</h1><p class="lede">Implementing SEO for Next.js applications</p><h1>Next.js SEO</h1>
<p><strong>Scope</strong>: Metadata API, Open Graph, structured data (JSON-LD), sitemaps, robots.txt <strong>Lines</strong>: ~280 <strong>Last Updated</strong>: 2025-10-18</p>
<h2>When to Use This Skill</h2>
<p>Activate this skill when:</p>
<ul><li>Implementing SEO for Next.js applications</li><li>Adding metadata and Open Graph tags</li><li>Creating sitemaps and robots.txt</li><li>Implementing structured data</li><li>Optimizing for social sharing</li><li>Improving search engine visibility</li></ul>
<h2>Core Concepts</h2>
<h3>SEO Fundamentals</h3>
<p><strong>On-page SEO</strong>:</p>
<ul><li>Title tags (50-60 characters)</li><li>Meta descriptions (150-160 characters)</li><li>Heading hierarchy (H1, H2, H3)</li><li>URL structure (descriptive, kebab-case)</li><li>Internal linking</li></ul>
<p><strong>Technical SEO</strong>:</p>
<ul><li>Sitemap.xml</li><li>Robots.txt</li><li>Canonical URLs</li><li>Structured data (JSON-LD)</li><li>Performance (Core Web Vitals)</li></ul>
<hr>
<h2>Metadata API</h2>
<h3>Static Metadata</h3>
<pre><code class="lang-tsx">// app/page.tsx
import type { Metadata } from &#x27;next&#x27;;
export const metadata: Metadata = {
title: &#x27;Home - My Website&#x27;,
description: &#x27;Welcome to my website. Discover amazing products and services.&#x27;,
keywords: [&#x27;product&#x27;, &#x27;service&#x27;, &#x27;website&#x27;],
authors: [{ name: &#x27;John Doe&#x27;, url: &#x27;https://example.com/authors/john&#x27; }],
creator: &#x27;John Doe&#x27;,
publisher: &#x27;My Company&#x27;,
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
&#x27;max-video-preview&#x27;: -1,
&#x27;max-image-preview&#x27;: &#x27;large&#x27;,
&#x27;max-snippet&#x27;: -1,
},
},
alternates: {
canonical: &#x27;https://example.com&#x27;,
languages: {
&#x27;en-US&#x27;: &#x27;https://example.com&#x27;,
&#x27;es-ES&#x27;: &#x27;https://example.com/es&#x27;,
},
},
};
export default function HomePage() {
return &lt;h1&gt;Home Page&lt;/h1&gt;;
}</code></pre>
<h3>Dynamic Metadata</h3>
<pre><code class="lang-tsx">// app/blog/[slug]/page.tsx
import type { Metadata } from &#x27;next&#x27;;
interface Props {
params: { slug: string };
}
export async function generateMetadata({ params }: Props): Promise&lt;Metadata&gt; {
// Fetch post data
const post = await getPost(params.slug);
return {
title: post.title,
description: post.excerpt,
authors: [{ name: post.author.name }],
openGraph: {
title: post.title,
description: post.excerpt,
type: &#x27;article&#x27;,
publishedTime: post.publishedAt,
authors: [post.author.name],
images: [
{
url: post.coverImage,
width: 1200,
height: 630,
alt: post.title,
},
],
},
twitter: {
card: &#x27;summary_large_image&#x27;,
title: post.title,
description: post.excerpt,
images: [post.coverImage],
},
};
}
export default function BlogPostPage({ params }: Props) {
return &lt;article&gt;...&lt;/article&gt;;
}</code></pre>
<h3>Title Templates</h3>
<pre><code class="lang-tsx">// app/layout.tsx
import type { Metadata } from &#x27;next&#x27;;
export const metadata: Metadata = {
title: {
default: &#x27;My Website&#x27;,
template: &#x27;%s | My Website&#x27;, // Page title will be &quot;About | My Website&quot;
},
description: &#x27;Default description&#x27;,
};
// app/about/page.tsx
export const metadata: Metadata = {
title: &#x27;About&#x27;, // Becomes &quot;About | My Website&quot;
};</code></pre>
<h3>Viewport and Theme Color</h3>
<pre><code class="lang-tsx">// app/layout.tsx
import type { Viewport } from &#x27;next&#x27;;
export const viewport: Viewport = {
width: &#x27;device-width&#x27;,
initialScale: 1,
maximumScale: 1,
themeColor: [
{ media: &#x27;(prefers-color-scheme: light)&#x27;, color: &#x27;#ffffff&#x27; },
{ media: &#x27;(prefers-color-scheme: dark)&#x27;, color: &#x27;#000000&#x27; },
],
};</code></pre>
<hr>
<h2>Open Graph and Twitter Cards</h2>
<h3>Open Graph Tags</h3>
<pre><code class="lang-tsx">// app/page.tsx
import type { Metadata } from &#x27;next&#x27;;
export const metadata: Metadata = {
title: &#x27;Product Name&#x27;,
description: &#x27;Product description&#x27;,
openGraph: {
type: &#x27;website&#x27;,
url: &#x27;https://example.com&#x27;,
title: &#x27;Product Name&#x27;,
description: &#x27;Product description&#x27;,
siteName: &#x27;My Website&#x27;,
locale: &#x27;en_US&#x27;,
images: [
{
url: &#x27;https://example.com/og-image.jpg&#x27;,
width: 1200,
height: 630,
alt: &#x27;Product preview&#x27;,
type: &#x27;image/jpeg&#x27;,
},
],
},
};</code></pre>
<h3>Twitter Cards</h3>
<pre><code class="lang-tsx">export const metadata: Metadata = {
twitter: {
card: &#x27;summary_large_image&#x27;, // or &#x27;summary&#x27;, &#x27;app&#x27;, &#x27;player&#x27;
site: &#x27;@mywebsite&#x27;,
creator: &#x27;@johndoe&#x27;,
title: &#x27;Product Name&#x27;,
description: &#x27;Product description&#x27;,
images: [&#x27;https://example.com/twitter-image.jpg&#x27;],
},
};</code></pre>
<h3>Article Metadata</h3>
<pre><code class="lang-tsx">// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }: Props): Promise&lt;Metadata&gt; {
const post = await getPost(params.slug);
return {
openGraph: {
type: &#x27;article&#x27;,
url: `https://example.com/blog/${params.slug}`,
title: post.title,
description: post.excerpt,
publishedTime: post.publishedAt,
modifiedTime: post.updatedAt,
authors: [post.author.name],
section: post.category,
tags: post.tags,
images: [
{
url: post.coverImage,
width: 1200,
height: 630,
},
],
},
};
}</code></pre>
<hr>
<h2>Structured Data (JSON-LD)</h2>
<h3>Organization</h3>
<pre><code class="lang-tsx">// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
const organizationSchema = {
&#x27;@context&#x27;: &#x27;https://schema.org&#x27;,
&#x27;@type&#x27;: &#x27;Organization&#x27;,
name: &#x27;My Company&#x27;,
url: &#x27;https://example.com&#x27;,
logo: &#x27;https://example.com/logo.png&#x27;,
sameAs: [
&#x27;https://twitter.com/mycompany&#x27;,
&#x27;https://facebook.com/mycompany&#x27;,
&#x27;https://linkedin.com/company/mycompany&#x27;,
],
contactPoint: {
&#x27;@type&#x27;: &#x27;ContactPoint&#x27;,
telephone: &#x27;+1-555-1234&#x27;,
contactType: &#x27;Customer Service&#x27;,
email: &#x27;[email protected]&#x27;,
},
};
return (
&lt;html&gt;
&lt;head&gt;
&lt;script
type=&quot;application/ld+json&quot;
dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationSchema) }}
/&gt;
&lt;/head&gt;
&lt;body&gt;{children}&lt;/body&gt;
&lt;/html&gt;
);
}</code></pre>
<h3>Article</h3>
<pre><code class="lang-tsx">// app/blog/[slug]/page.tsx
export default async function BlogPostPage({ params }: Props) {
const post = await getPost(params.slug);
const articleSchema = {
&#x27;@context&#x27;: &#x27;https://schema.org&#x27;,
&#x27;@type&#x27;: &#x27;Article&#x27;,
headline: post.title,
description: post.excerpt,
image: post.coverImage,
datePublished: post.publishedAt,
dateModified: post.updatedAt,
author: {
&#x27;@type&#x27;: &#x27;Person&#x27;,
name: post.author.name,
url: post.author.url,
},
publisher: {
&#x27;@type&#x27;: &#x27;Organization&#x27;,
name: &#x27;My Website&#x27;,
logo: {
&#x27;@type&#x27;: &#x27;ImageObject&#x27;,
url: &#x27;https://example.com/logo.png&#x27;,
},
},
mainEntityOfPage: {
&#x27;@type&#x27;: &#x27;WebPage&#x27;,
&#x27;@id&#x27;: `https://example.com/blog/${params.slug}`,
},
};
return (
&lt;&gt;
&lt;script
type=&quot;application/ld+json&quot;
dangerouslySetInnerHTML={{ __html: JSON.stringify(articleSchema) }}
/&gt;
&lt;article&gt;
&lt;h1&gt;{post.title}&lt;/h1&gt;
&lt;div dangerouslySetInnerHTML={{ __html: post.content }} /&gt;
&lt;/article&gt;
&lt;/&gt;
);
}</code></pre>
<h3>Product</h3>
<pre><code class="lang-tsx">// app/products/[id]/page.tsx
export default async function ProductPage({ params }: Props) {
const product = await getProduct(params.id);
const productSchema = {
&#x27;@context&#x27;: &#x27;https://schema.org&#x27;,
&#x27;@type&#x27;: &#x27;Product&#x27;,
name: product.name,
description: product.description,
image: product.images,
sku: product.sku,
brand: {
&#x27;@type&#x27;: &#x27;Brand&#x27;,
name: product.brand,
},
offers: {
&#x27;@type&#x27;: &#x27;Offer&#x27;,
url: `https://example.com/products/${params.id}`,
priceCurrency: &#x27;USD&#x27;,
price: product.price,
availability: product.inStock
? &#x27;https://schema.org/InStock&#x27;
: &#x27;https://schema.org/OutOfStock&#x27;,
priceValidUntil: &#x27;2025-12-31&#x27;,
},
aggregateRating: {
&#x27;@type&#x27;: &#x27;AggregateRating&#x27;,
ratingValue: product.rating,
reviewCount: product.reviewCount,
},
};
return (
&lt;&gt;
&lt;script
type=&quot;application/ld+json&quot;
dangerouslySetInnerHTML={{ __html: JSON.stringify(productSchema) }}
/&gt;
&lt;div&gt;
&lt;h1&gt;{product.name}&lt;/h1&gt;
&lt;p&gt;{product.description}&lt;/p&gt;
&lt;/div&gt;
&lt;/&gt;
);
}</code></pre>
<h3>Breadcrumbs</h3>
<pre><code class="lang-tsx">// app/blog/[category]/[slug]/page.tsx
const breadcrumbSchema = {
&#x27;@context&#x27;: &#x27;https://schema.org&#x27;,
&#x27;@type&#x27;: &#x27;BreadcrumbList&#x27;,
itemListElement: [
{
&#x27;@type&#x27;: &#x27;ListItem&#x27;,
position: 1,
name: &#x27;Home&#x27;,
item: &#x27;https://example.com&#x27;,
},
{
&#x27;@type&#x27;: &#x27;ListItem&#x27;,
position: 2,
name: &#x27;Blog&#x27;,
item: &#x27;https://example.com/blog&#x27;,
},
{
&#x27;@type&#x27;: &#x27;ListItem&#x27;,
position: 3,
name: category,
item: `https://example.com/blog/${category}`,
},
{
&#x27;@type&#x27;: &#x27;ListItem&#x27;,
position: 4,
name: post.title,
item: `https://example.com/blog/${category}/${slug}`,
},
],
};</code></pre>
<hr>
<h2>Sitemap</h2>
<h3>Static Sitemap</h3>
<pre><code class="lang-tsx">// app/sitemap.ts
import { MetadataRoute } from &#x27;next&#x27;;
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: &#x27;https://example.com&#x27;,
lastModified: new Date(),
changeFrequency: &#x27;daily&#x27;,
priority: 1,
},
{
url: &#x27;https://example.com/about&#x27;,
lastModified: new Date(),
changeFrequency: &#x27;monthly&#x27;,
priority: 0.8,
},
{
url: &#x27;https://example.com/blog&#x27;,
lastModified: new Date(),
changeFrequency: &#x27;weekly&#x27;,
priority: 0.9,
},
];
}</code></pre>
<h3>Dynamic Sitemap</h3>
<pre><code class="lang-tsx">// app/sitemap.ts
import { MetadataRoute } from &#x27;next&#x27;;
export default async function sitemap(): Promise&lt;MetadataRoute.Sitemap&gt; {
// Fetch dynamic content
const posts = await getPosts();
const products = await getProducts();
const postUrls = posts.map((post) =&gt; ({
url: `https://example.com/blog/${post.slug}`,
lastModified: post.updatedAt,
changeFrequency: &#x27;weekly&#x27; as const,
priority: 0.7,
}));
const productUrls = products.map((product) =&gt; ({
url: `https://example.com/products/${product.id}`,
lastModified: product.updatedAt,
changeFrequency: &#x27;daily&#x27; as const,
priority: 0.8,
}));
return [
{
url: &#x27;https://example.com&#x27;,
lastModified: new Date(),
changeFrequency: &#x27;daily&#x27;,
priority: 1,
},
...postUrls,
...productUrls,
];
}</code></pre>
<h3>Multiple Sitemaps</h3>
<pre><code class="lang-tsx">// app/sitemap.ts (index sitemap)
import { MetadataRoute } from &#x27;next&#x27;;
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: &#x27;https://example.com/sitemap/posts.xml&#x27;,
},
{
url: &#x27;https://example.com/sitemap/products.xml&#x27;,
},
];
}
// app/sitemap/posts/sitemap.ts
export default async function sitemap(): Promise&lt;MetadataRoute.Sitemap&gt; {
const posts = await getPosts();
return posts.map((post) =&gt; ({
url: `https://example.com/blog/${post.slug}`,
lastModified: post.updatedAt,
}));
}</code></pre>
<hr>
<h2>Robots.txt</h2>
<h3>Static Robots.txt</h3>
<pre><code class="lang-tsx">// app/robots.ts
import { MetadataRoute } from &#x27;next&#x27;;
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: &#x27;*&#x27;,
allow: &#x27;/&#x27;,
disallow: [&#x27;/api/&#x27;, &#x27;/admin/&#x27;, &#x27;/private/&#x27;],
},
sitemap: &#x27;https://example.com/sitemap.xml&#x27;,
};
}</code></pre>
<h3>Environment-Specific Robots.txt</h3>
<pre><code class="lang-tsx">// app/robots.ts
import { MetadataRoute } from &#x27;next&#x27;;
export default function robots(): MetadataRoute.Robots {
const isProduction = process.env.NODE_ENV === &#x27;production&#x27;;
return {
rules: {
userAgent: &#x27;*&#x27;,
allow: isProduction ? &#x27;/&#x27; : [],
disallow: isProduction ? [&#x27;/api/&#x27;, &#x27;/admin/&#x27;] : [&#x27;/&#x27;],
},
sitemap: isProduction ? &#x27;https://example.com/sitemap.xml&#x27; : undefined,
};
}</code></pre>
<hr>
<h2>Canonical URLs</h2>
<h3>Setting Canonical URL</h3>
<pre><code class="lang-tsx">// app/blog/[slug]/page.tsx
import type { Metadata } from &#x27;next&#x27;;
export async function generateMetadata({ params }: Props): Promise&lt;Metadata&gt; {
return {
alternates: {
canonical: `https://example.com/blog/${params.slug}`,
},
};
}</code></pre>
<h3>Handling Duplicates</h3>
<pre><code class="lang-tsx">// If content exists at multiple URLs, point to primary
export const metadata: Metadata = {
alternates: {
canonical: &#x27;https://example.com/primary-url&#x27;,
},
};</code></pre>
<hr>
<h2>URL Structure Best Practices</h2>
<h3>SEO-Friendly URLs</h3>
<pre><code>✅ Good:
https://example.com/blog/how-to-optimize-images
https://example.com/products/laptops/macbook-pro-2024
❌ Bad:
https://example.com/blog?id=12345
https://example.com/p/1a2b3c</code></pre>
<p><strong>Guidelines</strong>:</p>
<ul><li>Use hyphens (not underscores)</li><li>Lowercase only</li><li>Descriptive keywords</li><li>Short and readable</li><li>Avoid parameters when possible</li></ul>
<hr>
<h2>Quick Reference</h2>
<h3>Metadata Checklist</h3>
<pre><code>[ ] Title (50-60 characters)
[ ] Description (150-160 characters)
[ ] Open Graph tags (og:title, og:description, og:image)
[ ] Twitter Card tags
[ ] Canonical URL
[ ] Robots meta tag
[ ] Structured data (JSON-LD)
[ ] Sitemap.xml
[ ] Robots.txt
[ ] Alt text for images
[ ] Heading hierarchy (H1 → H6)</code></pre>
<h3>Essential Meta Tags</h3>
<pre><code class="lang-tsx">export const metadata: Metadata = {
title: &#x27;Page Title&#x27;,
description: &#x27;Page description&#x27;,
openGraph: {
title: &#x27;Page Title&#x27;,
description: &#x27;Page description&#x27;,
images: [&#x27;/og-image.jpg&#x27;],
},
twitter: {
card: &#x27;summary_large_image&#x27;,
title: &#x27;Page Title&#x27;,
description: &#x27;Page description&#x27;,
images: [&#x27;/twitter-image.jpg&#x27;],
},
alternates: {
canonical: &#x27;https://example.com/page&#x27;,
},
};</code></pre>
<h3>Structured Data Types</h3>
<pre><code>Organization - Company info
Article - Blog posts
Product - E-commerce products
BreadcrumbList - Navigation breadcrumbs
FAQPage - FAQ pages
LocalBusiness - Local business info
Recipe - Recipe content
Review - Product/service reviews
Event - Event listings
VideoObject - Video content</code></pre>
<hr>
<h2>SEO Testing Tools</h2>
<p><strong>Google Tools</strong>:</p>
<ul><li>Google Search Console</li><li>Google Rich Results Test</li><li>PageSpeed Insights</li></ul>
<p><strong>Third-party Tools</strong>:</p>
<ul><li>Screaming Frog SEO Spider</li><li>Ahrefs Site Audit</li><li>SEMrush Site Audit</li><li>Lighthouse (Chrome DevTools)</li></ul>
<hr>
<h2>Common Anti-Patterns</h2>
<p>❌ <strong>Missing title/description</strong>: Search engines generate own (poor quality) ✅ Always provide custom metadata</p>
<p>❌ <strong>Duplicate content</strong>: Multiple URLs with same content ✅ Use canonical URLs</p>
<p>❌ <strong>Blocking crawlers</strong>: robots.txt blocks important pages ✅ Only block admin/API routes</p>
<p>❌ <strong>Missing structured data</strong>: Reduced search visibility ✅ Implement JSON-LD for content types</p>
<p>❌ <strong>Poor URL structure</strong>: Non-descriptive, parameter-heavy URLs ✅ Use clean, keyword-rich URLs</p>
<hr>
<h2>Level 3: Resources</h2>
<p>This skill includes comprehensive Level 3 resources in <code>skills/frontend/nextjs-seo/resources/</code>:</p>
<h3>Reference Documentation</h3>
<p><strong>REFERENCE.md</strong> (~1000 lines): Comprehensive reference guide covering:</p>
<ul><li>Metadata API (static and dynamic)</li><li>Open Graph Protocol (website, article, product, video)</li><li>Twitter Cards (all card types)</li><li>Structured data (JSON-LD schemas for all content types)</li><li>Sitemap generation (static, dynamic, multi-language)</li><li>Robots.txt configuration</li><li>Canonical URLs</li><li>Meta tags best practices</li><li>Core Web Vitals and performance</li><li>Image optimization for SEO</li><li>Internationalization (i18n) for SEO</li><li>Advanced patterns and testing</li></ul>
<h3>Executable Scripts</h3>
<p>Located in <code>resources/scripts/</code>:</p>
<ol><li><strong>check_seo.py</strong> - SEO tag validation tool</li></ol>
<ul><li>Validates meta tags, Open Graph, Twitter Cards, structured data</li><li>Checks title/description lengths</li><li>Verifies canonical URLs and robots directives</li><li>Reports issues, warnings, and successes</li><li>JSON output support</li><li>Usage: <code>./check_seo.py &lt;url&gt; [--json] [--output file.json]</code></li></ul>
<ol><li><strong>generate_sitemap.py</strong> - Next.js sitemap generator</li></ol>
<ul><li>Scans App Router directory structure</li><li>Supports dynamic routes ([param], [...slug], [[...slug]])</li><li>Auto-assigns priorities based on path depth</li><li>Customizable exclusions</li><li>XML and JSON output</li><li>Usage: <code>./generate_sitemap.py [--app-dir ./app] [--base-url https://example.com] [--output public/sitemap.xml]</code></li></ul>
<ol><li><strong>test_metadata.js</strong> - Metadata validation utility</li></ol>
<ul><li>Analyzes Next.js page files for metadata exports</li><li>Validates static and dynamic metadata</li><li>Checks for required fields</li><li>TypeScript type checking</li><li>Error handling validation</li><li>Usage: <code>./test_metadata.js &lt;path-to-page&gt; [--json] [--params id=123]</code></li></ul>
<h3>TypeScript Examples</h3>
<p>Located in <code>resources/examples/typescript/</code>:</p>
<ol><li><strong>app-router-metadata.tsx</strong> - Complete metadata examples</li></ol>
<ul><li>Static metadata (layouts and pages)</li><li>Dynamic metadata with database queries</li><li>Multi-language metadata</li><li>Environment-based metadata</li><li>Paginated content</li><li>Error handling patterns</li></ul>
<ol><li><strong>dynamic-og-images.tsx</strong> - Dynamic OG image generation</li></ol>
<ul><li>Basic dynamic images with next/og</li><li>Blog post images with custom fonts</li><li>Product images with layouts</li><li>Author profile images</li><li>Stats/metrics images</li><li>Multi-style images based on category</li><li>Branded images with logos</li></ul>
<ol><li><strong>structured-data.ts</strong> - JSON-LD schema examples</li></ol>
<ul><li>Organization schema</li><li>Article schema</li><li>Product schema (with reviews and ratings)</li><li>Breadcrumb schema</li><li>FAQ schema</li><li>Local business schema</li><li>WebSite search action</li><li>Video schema</li><li>Course schema</li><li>Event schema</li><li>Reusable TypeScript types and components</li></ul>
<ol><li><strong>sitemap.ts</strong> - Sitemap generation patterns</li></ol>
<ul><li>Static sitemaps</li><li>Dynamic sitemaps with database</li><li>Multi-language sitemaps</li><li>Custom priority calculations</li><li>Exclusion filters</li><li>Paginated content</li><li>Sitemap indexes for large sites</li><li>Caching strategies</li><li>Error handling</li></ul>
<ol><li><strong>robots.ts</strong> - robots.txt patterns</li></ol>
<ul><li>Basic robots.txt</li><li>Multiple user agents</li><li>Environment-specific rules</li><li>E-commerce configurations</li><li>Blog/content site rules</li><li>SaaS application rules</li><li>Custom crawl delays</li><li>Block specific bots</li><li>Regional configurations</li><li>Helper functions</li></ul>
<p>All scripts are executable with <code>--help</code> flags and support <code>--json</code> output for automation.</p>
<hr>
<h2>Related Skills</h2>
<ul><li><code>nextjs-app-router.md</code> - Metadata API, generateMetadata</li><li><code>frontend-performance.md</code> - Core Web Vitals (affects SEO)</li><li><code>web-accessibility.md</code> - Semantic HTML, alt text</li></ul>
<hr>
<p><strong>Last Updated</strong>: 2025-10-27 <strong>Format Version</strong>: 1.0 (Atomic)</p>
<footer>
<div class="fmap">
<div><b>Build</b>
<a href="https://hanzo.app">hanzo.app</a> app builder
<a href="https://hanzo.codes">hanzo.codes</a> code with an agent
<a href="https://hanzoskills.com">hanzoskills.com</a> what an agent reads</div>
<div><b>Run</b>
<a href="https://console.hanzo.ai">console.hanzo.ai</a> cloud console
<a href="https://api.hanzo.ai">api.hanzo.ai</a> the API</div>
<div><b>Account</b>
<a href="https://hanzo.id">hanzo.id</a> sign in
<a href="https://pay.hanzo.ai">pay.hanzo.ai</a> top up
<a href="https://billing.hanzo.ai">billing.hanzo.ai</a> invoices and usage</div>
<div><b>Company</b>
<a href="https://hanzo.ai">hanzo.ai</a> canonical
<a href="https://hanzo.ventures">hanzo.ventures</a> ventures</div>
</div>
<div class="fend"><a href="/frontend-nextjs-seo.md">This page as plain text</a> · <a href="/llms.txt">Index for agents</a></div>
</footer>
</div></body></html>