Merge pull request '[Feature] SEO + GEO: sitemap, robots, JSON-LD, canonical & article metadata, llms.txt' (#1) from feature_seo_geo into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -3,6 +3,7 @@ import { getAllPosts, getPostBySlug } from "@/lib/blog";
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import { MDXRemote } from "next-mdx-remote/rsc";
|
||||
import { mdxComponents } from "@/components/blog/MDXComponents";
|
||||
import { JsonLd } from "@/components/JsonLd";
|
||||
import rehypeHighlight from "rehype-highlight";
|
||||
import Link from "next/link";
|
||||
import type { Metadata } from "next";
|
||||
@@ -19,9 +20,29 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const post = getPostBySlug(slug);
|
||||
if (!post) return {};
|
||||
|
||||
const url = `${siteConfig.url}/blog/${slug}`;
|
||||
const image = post.image ?? siteConfig.seo.ogImage;
|
||||
|
||||
return {
|
||||
title: `${post.title} | ${siteConfig.name}`,
|
||||
title: post.title,
|
||||
description: post.description,
|
||||
alternates: { canonical: `/blog/${slug}` },
|
||||
openGraph: {
|
||||
type: "article",
|
||||
title: post.title,
|
||||
description: post.description,
|
||||
url,
|
||||
publishedTime: post.date || undefined,
|
||||
authors: [siteConfig.name],
|
||||
images: [{ url: image, alt: post.title }],
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: post.title,
|
||||
description: post.description,
|
||||
images: [image],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,8 +56,31 @@ export default async function BlogPostPage({ params }: Props) {
|
||||
const prev = idx < allPosts.length - 1 ? allPosts[idx + 1] : null;
|
||||
const next = idx > 0 ? allPosts[idx - 1] : null;
|
||||
|
||||
const url = `${siteConfig.url}/blog/${slug}`;
|
||||
const articleSchema = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
headline: post.title,
|
||||
description: post.description,
|
||||
datePublished: post.date || undefined,
|
||||
author: { "@type": "Person", name: siteConfig.name, url: siteConfig.url },
|
||||
image: post.image ?? siteConfig.seo.ogImage,
|
||||
mainEntityOfPage: url,
|
||||
url,
|
||||
};
|
||||
const breadcrumbSchema = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
itemListElement: [
|
||||
{ "@type": "ListItem", position: 1, name: "Blog", item: `${siteConfig.url}/blog` },
|
||||
{ "@type": "ListItem", position: 2, name: post.title, item: url },
|
||||
],
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="mx-auto min-h-dvh max-w-3xl px-6 pt-32 pb-16">
|
||||
<JsonLd data={articleSchema} />
|
||||
<JsonLd data={breadcrumbSchema} />
|
||||
<Link
|
||||
href="/blog"
|
||||
className="mb-8 inline-flex items-center gap-1 text-sm text-secondary transition-colors hover:text-accent"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { getAllPosts, getAllTags } from "@/lib/blog";
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import type { Metadata } from "next";
|
||||
import { BlogListClient } from "./BlogListClient";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Blog | ${siteConfig.name}`,
|
||||
title: "Blog",
|
||||
description: "Thoughts on code, design, and building things on the web.",
|
||||
alternates: { canonical: "/blog" },
|
||||
};
|
||||
|
||||
export default function BlogPage() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import type { Metadata } from "next";
|
||||
import { InterestsClient } from "./InterestsClient";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Interests | ${siteConfig.name}`,
|
||||
title: "Interests",
|
||||
description: "What I'm up to across the web — a live feed of my activity.",
|
||||
alternates: { canonical: "/interests" },
|
||||
};
|
||||
|
||||
export default function InterestsPage() {
|
||||
|
||||
+32
-3
@@ -3,9 +3,32 @@ import { Inter, JetBrains_Mono } from "next/font/google";
|
||||
import { ThemeProvider } from "next-themes";
|
||||
import { GlassNav } from "@/components/ui/GlassNav";
|
||||
import { Analytics } from "@/components/Analytics";
|
||||
import { JsonLd } from "@/components/JsonLd";
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import "./globals.css";
|
||||
|
||||
const sameAs = Object.values(siteConfig.social).filter(
|
||||
(v) => v.startsWith("http"),
|
||||
);
|
||||
|
||||
const personSchema = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Person",
|
||||
name: siteConfig.name,
|
||||
url: siteConfig.url,
|
||||
jobTitle: siteConfig.seo.jobTitle,
|
||||
description: siteConfig.description,
|
||||
...(sameAs.length ? { sameAs } : {}),
|
||||
};
|
||||
|
||||
const websiteSchema = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
name: siteConfig.name,
|
||||
url: siteConfig.url,
|
||||
author: { "@type": "Person", name: siteConfig.name },
|
||||
};
|
||||
|
||||
const inter = Inter({
|
||||
variable: "--font-inter",
|
||||
subsets: ["latin"],
|
||||
@@ -19,9 +42,13 @@ const jetbrainsMono = JetBrains_Mono({
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: siteConfig.name,
|
||||
title: {
|
||||
default: siteConfig.name,
|
||||
template: `%s | ${siteConfig.name}`,
|
||||
},
|
||||
description: siteConfig.description,
|
||||
metadataBase: new URL(siteConfig.url),
|
||||
alternates: { canonical: "/" },
|
||||
openGraph: {
|
||||
title: siteConfig.name,
|
||||
description: siteConfig.description,
|
||||
@@ -30,7 +57,7 @@ export const metadata: Metadata = {
|
||||
type: "website",
|
||||
images: [
|
||||
{
|
||||
url: "/images/og.png",
|
||||
url: siteConfig.seo.ogImage,
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: siteConfig.name,
|
||||
@@ -41,7 +68,7 @@ export const metadata: Metadata = {
|
||||
card: "summary_large_image",
|
||||
title: siteConfig.name,
|
||||
description: siteConfig.description,
|
||||
images: ["/images/og.png"],
|
||||
images: [siteConfig.seo.ogImage],
|
||||
},
|
||||
icons: {
|
||||
icon: [
|
||||
@@ -66,6 +93,8 @@ export default function RootLayout({
|
||||
className={`${inter.variable} ${jetbrainsMono.variable}`}
|
||||
>
|
||||
<body className="min-h-dvh bg-surface font-sans text-primary antialiased">
|
||||
<JsonLd data={personSchema} />
|
||||
<JsonLd data={websiteSchema} />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme={siteConfig.theme.defaultTheme}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import { getAllPosts } from "@/lib/blog";
|
||||
|
||||
// ponytail: GEO ROI is unproven (see designs/geo-strategy.md) but this is
|
||||
// near-zero cost and auto-generated, so it can't go stale.
|
||||
export function GET() {
|
||||
const { name, title, description, url } = siteConfig;
|
||||
const posts = getAllPosts();
|
||||
|
||||
const body = `# ${name}
|
||||
|
||||
> ${title}. ${description}
|
||||
|
||||
## Pages
|
||||
|
||||
- [Home](${url}/): About, projects, and contact for ${name}
|
||||
- [Blog](${url}/blog): Posts on code, design, and building things on the web
|
||||
- [Stack](${url}/stack): Self-hosted services and homelab infrastructure
|
||||
- [Interests](${url}/interests): Live feed of activity across the web
|
||||
|
||||
## Blog posts
|
||||
${posts
|
||||
.map((p) => `- [${p.title}](${url}/blog/${p.slug}): ${p.description}`)
|
||||
.join("\n")}
|
||||
`;
|
||||
|
||||
return new Response(body, {
|
||||
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { siteConfig } from "@/lib/config";
|
||||
|
||||
// ponytail: single allow-all rule covers AI crawlers (GPTBot, PerplexityBot,
|
||||
// ClaudeBot, Google-Extended, etc.) too — we WANT them for GEO. Add per-bot
|
||||
// rules only if a specific crawler ever needs blocking.
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: {
|
||||
userAgent: "*",
|
||||
allow: "/",
|
||||
disallow: "/api/",
|
||||
},
|
||||
sitemap: `${siteConfig.url}/sitemap.xml`,
|
||||
host: siteConfig.url,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import { getAllPosts } from "@/lib/blog";
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const base = siteConfig.url;
|
||||
|
||||
const staticRoutes = ["", "/blog", "/stack", "/interests"].map((path) => ({
|
||||
url: `${base}${path}`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: "weekly" as const,
|
||||
priority: path === "" ? 1 : 0.7,
|
||||
}));
|
||||
|
||||
const posts = getAllPosts().map((post) => ({
|
||||
url: `${base}/blog/${post.slug}`,
|
||||
lastModified: post.date ? new Date(post.date) : new Date(),
|
||||
changeFrequency: "monthly" as const,
|
||||
priority: 0.6,
|
||||
}));
|
||||
|
||||
return [...staticRoutes, ...posts];
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { siteConfig } from "@/lib/config";
|
||||
import type { Metadata } from "next";
|
||||
import { StackPageClient } from "./StackPageClient";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `Stack | ${siteConfig.name}`,
|
||||
title: "Stack",
|
||||
description: "Self-hosted services and infrastructure I run.",
|
||||
alternates: { canonical: "/stack" },
|
||||
};
|
||||
|
||||
export default function StackPage() {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Renders a JSON-LD structured-data script. Used for Person/WebSite/BlogPosting.
|
||||
export function JsonLd({ data }: { data: Record<string, unknown> }) {
|
||||
return (
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+3
-2
@@ -36,7 +36,7 @@ export const siteConfig = {
|
||||
"This site — built with Next.js 16, React Three Fiber, shader gradients, and liquid glass effects.",
|
||||
tags: ["Next.js", "React Three Fiber", "GLSL", "Tailwind"],
|
||||
url: "https://daniel.dou.bet",
|
||||
github: "https://github.com/iamdoubz/me",
|
||||
github: "https://git.dou.bet/iamdoubz/me",
|
||||
},
|
||||
{
|
||||
title: "gmmff",
|
||||
@@ -90,7 +90,8 @@ export const siteConfig = {
|
||||
],
|
||||
|
||||
seo: {
|
||||
ogImage: "/og/default.jpg",
|
||||
ogImage: "/images/og.png",
|
||||
jobTitle: "Consultant",
|
||||
},
|
||||
|
||||
analytics: {
|
||||
|
||||
Reference in New Issue
Block a user