From a86a420f61dc819c194092bae22b6cef55aadea3 Mon Sep 17 00:00:00 2001 From: Zeeshan Adil Date: Thu, 12 Nov 2026 18:13:02 +0500 Subject: [PATCH] fix(seo): titles and descriptions that fit a search result The crawl still listed five post titles and seven descriptions longer than a search result shows, so search engines cut them mid-sentence. - A post or guide can carry a seoTitle: a shorter headline for the browser tab and search results. The headline on the page is unchanged. Five posts get one, each a cut of the post's own title. - Descriptions in the page's meta tags are kept to whole sentences within 160 characters. The page and the structured data keep the full text. - The DWOSI and mentorship descriptions are tightened to fit. - llms.txt and llms-full.txt point to the learning resources site, which lives on its own subdomain. --- app/blog/[slug]/page.tsx | 7 ++++--- app/dwosi/page.tsx | 2 +- app/guides/[slug]/page.tsx | 6 +++--- app/llms-full.txt/route.ts | 1 + app/llms.txt/route.ts | 1 + app/mentorship/page.tsx | 2 +- content/blog/fellowship-2025-impact-report.md | 1 + content/blog/fellowship-2026-impact-report.md | 1 + content/blog/fellowship-2026-next-steps.md | 1 + content/blog/gsoc.md | 1 + .../blog/lfx-mentorship-2026-talha-amjad.md | 1 + lib/seo.ts | 19 +++++++++++++++++++ 12 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx index a5cbe9e..d4b4fce 100644 --- a/app/blog/[slug]/page.tsx +++ b/app/blog/[slug]/page.tsx @@ -7,7 +7,7 @@ import Link from "next/link"; import { ArticleBody } from "@/components/content/article-body"; import { formatDate } from "@/components/content/format-date"; import { Button, Eyebrow, container } from "@/components/site/page-kit"; -import { SITE_NAME, blogPostingJsonLd, excerptOf, jsonLdString, pageTitle, withSocial } from "@/lib/seo"; +import { SITE_NAME, blogPostingJsonLd, excerptOf, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo"; const backLink = "inline-flex min-h-11 items-center text-[15px] font-medium text-[#5C5C5C] transition-colors hover:text-[#0A0A0A]"; @@ -31,9 +31,10 @@ export async function generateMetadata({ if (!fs.existsSync(filePath)) return { title: "Post not found", robots: { index: false } }; const { data, content } = matter(fs.readFileSync(filePath, "utf-8")); const date = data.date ? new Date(data.date) : undefined; - const description = data.description ?? excerptOf(content); + const description = snippetOf(data.description) ?? excerptOf(content); return withSocial({ - title: pageTitle(data.title), + // seoTitle is a shorter headline for the browser tab and search results only + title: pageTitle(data.seoTitle ?? data.title), description, alternates: { canonical: `/blog/${slug}` }, openGraph: { diff --git a/app/dwosi/page.tsx b/app/dwosi/page.tsx index 63a1314..b809a4e 100644 --- a/app/dwosi/page.tsx +++ b/app/dwosi/page.tsx @@ -17,7 +17,7 @@ import { const title = "DWOSI ยท Dev Weekends Open Source Initiative" const description = - "Where early-career engineers prove their work in public. A free open source initiative where contributors build live products, with every pull request reviewed by product maintainers." + "Where early-career engineers prove their work in public. A free open source initiative: contributors build live products, maintainers review every pull request." export const metadata: Metadata = { title: { absolute: title }, diff --git a/app/guides/[slug]/page.tsx b/app/guides/[slug]/page.tsx index be4591c..f3991d8 100644 --- a/app/guides/[slug]/page.tsx +++ b/app/guides/[slug]/page.tsx @@ -6,7 +6,7 @@ import type { Metadata } from "next"; import { ArticleBody } from "@/components/content/article-body"; import { formatDate } from "@/components/content/format-date"; import { Button, Eyebrow, container } from "@/components/site/page-kit"; -import { blogPostingJsonLd, jsonLdString, pageTitle, withSocial } from "@/lib/seo"; +import { blogPostingJsonLd, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo"; import { svgSize } from "@/lib/svg-size"; const guidesDir = path.join(process.cwd(), "content", "guides"); @@ -35,8 +35,8 @@ export async function generateMetadata({ const guide = readGuide(slug); if (!guide) return { title: "Guide not found", robots: { index: false } }; return withSocial({ - title: pageTitle(guide.data.title), - description: guide.data.description ?? "", + title: pageTitle(guide.data.seoTitle ?? guide.data.title), + description: snippetOf(guide.data.description) ?? "", alternates: { canonical: `/guides/${slug}` }, }); } diff --git a/app/llms-full.txt/route.ts b/app/llms-full.txt/route.ts index 033159a..a0bdda0 100644 --- a/app/llms-full.txt/route.ts +++ b/app/llms-full.txt/route.ts @@ -51,6 +51,7 @@ Everything Dev Weekends runs is free for members. Any page below can be read as - [Ambassadors](${SITE_URL}/ambassadors): The people who represent and grow the community around the world - [Sessions](${SITE_URL}/sessions): Past and upcoming talks and workshops - [Projects](${SITE_URL}/projects): Projects built by members +- [Resources](https://resources.devweekends.com): The free learning hub on its own site: system design, low-level design, DSA patterns, AWS, AI engineering, operating systems, courses and case studies - [Partners](${SITE_URL}/partners): The organisations and communities working with Dev Weekends - [Network](${SITE_URL}/network): Mentors and mentees and how they connect diff --git a/app/llms.txt/route.ts b/app/llms.txt/route.ts index 5e0ce5b..48471de 100644 --- a/app/llms.txt/route.ts +++ b/app/llms.txt/route.ts @@ -20,6 +20,7 @@ Every public page is also available as Markdown: request it with the header \`Ac - [Community](https://www.devweekends.com/community): Discord, WhatsApp groups and live sessions, and how to join - [Partners](https://www.devweekends.com/partners): The organisations and communities working with Dev Weekends - [Projects](https://www.devweekends.com/projects): Projects built by members +- [Resources](https://resources.devweekends.com): The free learning hub on its own site: system design, low-level design, DSA patterns, AWS, AI engineering, operating systems, courses and case studies - [Blog](https://www.devweekends.com/blog): News, guides and articles ## Machine-readable discovery diff --git a/app/mentorship/page.tsx b/app/mentorship/page.tsx index bbc5fb0..213fa6a 100644 --- a/app/mentorship/page.tsx +++ b/app/mentorship/page.tsx @@ -11,7 +11,7 @@ export const metadata: Metadata = withSocial({ alternates: { canonical: "/mentorship" }, title: "Mentorship", description: - "Dev Weekends mentorship: a free 3-month program with a personal mentor, live coding sessions and job preparation. It runs all year, except while a fellowship is running.", + "Dev Weekends mentorship: a free 3-month program with a personal mentor, live coding sessions and job preparation. It runs all year, except during a fellowship.", }) const body = "mt-3 text-[15px] leading-[1.6] text-[#5C5C5C]" diff --git a/content/blog/fellowship-2025-impact-report.md b/content/blog/fellowship-2025-impact-report.md index 57bc65e..55b9311 100644 --- a/content/blog/fellowship-2025-impact-report.md +++ b/content/blog/fellowship-2025-impact-report.md @@ -1,5 +1,6 @@ --- title: "Summer Fellowship 2025 impact report: 800 fellows, 100 certified, 442 projects" +seoTitle: "Summer Fellowship 2025 impact report: 800 fellows, 442 projects" date: "2025-09-21" category: "news" featured: false diff --git a/content/blog/fellowship-2026-impact-report.md b/content/blog/fellowship-2026-impact-report.md index 51d5844..f1a75f4 100644 --- a/content/blog/fellowship-2026-impact-report.md +++ b/content/blog/fellowship-2026-impact-report.md @@ -1,5 +1,6 @@ --- title: "Fellowship 2026 impact report: 1,072 fellows, 474 projects, 79 internships" +seoTitle: "Fellowship 2026 impact report: 1,072 fellows, 474 projects" date: "2026-11-06" category: "news" featured: false diff --git a/content/blog/fellowship-2026-next-steps.md b/content/blog/fellowship-2026-next-steps.md index d79d83c..4c9c27f 100644 --- a/content/blog/fellowship-2026-next-steps.md +++ b/content/blog/fellowship-2026-next-steps.md @@ -1,5 +1,6 @@ --- title: "Fellowship 2026 applications are now closed. Here is what comes next" +seoTitle: "Fellowship 2026 applications are closed. What comes next" date: "2026-06-05" category: "news" featured: true diff --git a/content/blog/gsoc.md b/content/blog/gsoc.md index becee8f..ffa569c 100644 --- a/content/blog/gsoc.md +++ b/content/blog/gsoc.md @@ -1,5 +1,6 @@ --- title: "9 Dev Weekends contributors got into Google Summer of Code 2026, and 5 more into other open-source programs" +seoTitle: "9 Dev Weekends contributors got into Google Summer of Code 2026" date: "2026-05-06" category: "news" featured: true diff --git a/content/blog/lfx-mentorship-2026-talha-amjad.md b/content/blog/lfx-mentorship-2026-talha-amjad.md index bf97650..2cf3401 100644 --- a/content/blog/lfx-mentorship-2026-talha-amjad.md +++ b/content/blog/lfx-mentorship-2026-talha-amjad.md @@ -1,5 +1,6 @@ --- title: "Talha Amjad selected for LFX Mentorship 2026 at CNCF, contributing to Volcano" +seoTitle: "Talha Amjad selected for LFX Mentorship 2026 at CNCF" date: "2026-09-23" category: "news" featured: true diff --git a/lib/seo.ts b/lib/seo.ts index e245a8c..9dca7f6 100644 --- a/lib/seo.ts +++ b/lib/seo.ts @@ -69,6 +69,25 @@ export function excerptOf(markdown: string, max = 155): string | undefined { return `${text.slice(0, text.lastIndexOf(' ', max - 1)).replace(/[\s,;:.]+$/, '')}...` } +/** + * A description cut to what a search result shows (about 160 characters): + * whole sentences while they fit, otherwise the first one cut at a word. The + * page itself still shows the full text. + */ +export function snippetOf(text: string | undefined, max = 160): string | undefined { + if (!text) return undefined + const clean = text.replace(/\s+/g, ' ').trim() + if (clean.length <= max) return clean + let kept = '' + for (const sentence of clean.split(/(?<=[.!?])\s+(?=[A-Z0-9"'])/)) { + const next = kept ? `${kept} ${sentence}` : sentence + if (next.length > max) break + kept = next + } + if (kept.length >= 70) return kept + return `${clean.slice(0, clean.lastIndexOf(' ', max - 4)).replace(/[\s,;:.]+$/, '')}...` +} + /** Long headlines fill the search result by themselves, so they go without the site name */ export function pageTitle(title: string): string | { absolute: string } { return title.length > 48 ? { absolute: title } : title