Skip to content

fix(webapp): truncate SEO titles on tag and source pages#5683

Merged
nimrodkra merged 3 commits intomainfrom
seo/pr1-title-truncation
Mar 9, 2026
Merged

fix(webapp): truncate SEO titles on tag and source pages#5683
nimrodkra merged 3 commits intomainfrom
seo/pr1-title-truncation

Conversation

@nimrodkra
Copy link
Member

@nimrodkra nimrodkra commented Mar 9, 2026

Summary

  • switch tag page SEO title generation to getPageSeoTitles so long titles are truncated consistently
  • switch source page SEO title generation to getPageSeoTitles with the same behavior
  • preserve full Open Graph titles while keeping metadata title length bounded

Why this matters

Keeping titles within a healthy length improves how results are rendered in search and reduces low-quality truncation in SERPs. This also standardizes title behavior across key page types, which makes SEO signals more consistent.

Test plan

  • pnpm --filter webapp lint
  • pnpm --filter webapp build (fails locally due DNS lookup for api.local.fylla.dev during prerender in this environment)

Made with Cursor

Preview domain

https://seo-pr1-title-truncation.preview.app.daily.dev

Reuse getPageSeoTitles on tag and source detail pages so long SEO titles are truncated consistently while preserving full Open Graph titles.

Made-with: Cursor
@vercel
Copy link

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-webapp Ready Ready Preview Mar 9, 2026 2:14pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
storybook Ignored Ignored Mar 9, 2026 2:14pm

Request Review

@nimrodkra
Copy link
Member Author

@claude please review this pr

@claude
Copy link
Contributor

claude bot commented Mar 9, 2026

Claude finished @nimrodkra's task in 2m 3s —— View job


PR Review

  • Gather context
  • Read changed files
  • Analyze changes
  • Post review feedback

Overall: Clean, focused change. Looks good to merge with a couple of minor notes.

The PR correctly ports both the tag and source pages to getPageSeoTitles, bringing them in line with the rest of the webapp. No functional issues found.


What this PR does

Before (both pages):

// [source].tsx
const seo: NextSeoProps = {
  title: `${source.name} posts on daily.dev`,
  openGraph: { ...defaultOpenGraph },  // ← BUG: overwritten by ...defaultSeo below
  ...defaultSeo,
  ...
};

// [tag].tsx
const getSeoData = (...): NextSeoProps => ({
  title: `${title} posts on daily.dev`,
  openGraph: { ...defaultOpenGraph },  // ← same bug
  ...defaultSeo,
  ...
});

After:

const seoTitles = getPageSeoTitles(`${source.name} posts`);
const seo: NextSeoProps = {
  ...defaultSeo,
  ...seoTitles,
  openGraph: { ...defaultOpenGraph, ...seoTitles.openGraph },  // ✅ correct merge order
  ...
};

Observations

1. Bonus bug fix: openGraph spread order
Both original files had a silent bug — openGraph: { ...defaultOpenGraph } was placed before ...defaultSeo, meaning defaultSeo.openGraph would silently overwrite it. The new code correctly merges them with defaultOpenGraph as base and seoTitles.openGraph (just the title) applied on top. Nice fix.

2. Title format change: "on daily.dev" → "| daily.dev"
The old title was "React posts on daily.dev", the new one is "React posts | daily.dev" (or truncated). This is consistent with every other page in the app and is the right call for SEO.

3. "Drop suffix" edge case is expected and tested
getTemplatedTitle silently drops | daily.dev for titles between 49–60 chars (avoids exceeding the 60-char limit). This is documented in utils.spec.ts and is the existing accepted trade-off for the whole site — not introduced by this PR.

4. OG title is correctly untruncated
getPageSeoTitles returns openGraph: { title: '${title} | daily.dev' } (full, untruncated), which is correctly preserved in the new code. Social sharing will always see the full title. ✅

5. Minor: getSeoData helper positioning in [tag].tsx
getSeoData is defined at line 472, after the component and export default. This is consistent with how the file was structured before, so no regression, but worth noting that the helper could be moved higher for readability. Not a blocker.


Test plan gap

The PR notes the build fails locally due to DNS. The linter passes. Given the narrowness of the change (no logic added, only reusing an already-tested utility), this is low risk to merge.
| Preview

@nimrodkra nimrodkra merged commit 1d35d4b into main Mar 9, 2026
11 checks passed
@nimrodkra nimrodkra deleted the seo/pr1-title-truncation branch March 9, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants