Skip to content

feat(seo): optimize page titles and meta descriptions#115

Merged
prudentbird merged 1 commit into
devfrom
feat/seo-105-page-titles-meta
Jun 5, 2026
Merged

feat(seo): optimize page titles and meta descriptions#115
prudentbird merged 1 commit into
devfrom
feat/seo-105-page-titles-meta

Conversation

@prudentbird

Copy link
Copy Markdown
Member

Summary

Gives every public page a deliberate, keyword-targeted <title> and meta description, and lays the shared foundation the rest of the SEO stack builds on.

  • src/lib/site.ts — single source of truth for product name, legal name, canonical URL, description, keyword targets, contact email, and social profiles. Reused by Open Graph, robots, sitemap, JSON-LD, and llms.txt in the following PRs.
  • NEXT_PUBLIC_SITE_URL added to env.ts, defaulting to https://retailytics.ajared.ng.
  • Root layoutmetadataBase, title template (%s · Retailytics), keyword-targeted default title/description, authors/creator/publisher.
  • Home — explicit unique title (Retailytics — Turn Local Data into Market Intelligence, 54 chars) + description (145 chars) + canonical.
  • Auth pages (login / register / forgot-password) — unique titles & descriptions, canonicals, and noindex,follow so thin utility pages don't dilute the index.

Done when (issue #105)

  • Every public page has a unique <title> under 60 chars and a unique meta description (120–155 chars) with a soft CTA.
  • Titles and descriptions are keyword-targeted to what users actually search for.

Validation

  • npm run typecheck
  • npm run build
  • npm run lint fails on a pre-existing toolchain incompatibility (eslint-plugin-react 7.37.5 vs ESLint 10), unrelated to this change.

Notes

First in a stack of SEO PRs (#105#106#112#107#108#109#110#111). Targets dev.

Closes #105

Add deliberate, keyword-targeted titles and meta descriptions across the
public surface, backed by a shared site config used by the rest of the SEO
work.

- Add src/lib/site.ts as the single source of truth for product name,
  canonical URL, description, keywords, contact and social profiles.
- Add NEXT_PUBLIC_SITE_URL (defaults to the production domain) to env.
- Root layout: metadataBase, title template, default keyword-targeted
  title/description, authors/creator/publisher.
- Home: explicit unique title + description + canonical.
- Auth pages (login/register/forgot-password): unique titles and
  descriptions, canonicals, and noindex,follow for thin utility pages.

Refs #105
@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown

Claude finished @prudentbird's task —— View job


Code Review Complete ✅

Review Checklist:

  • Read repository guidelines (CLAUDE.md)
  • Analyze new site configuration (src/lib/site.ts)
  • Review metadata implementation in layout.tsx
  • Check page-specific metadata (home, auth pages)
  • Evaluate environment variable usage
  • Assess code quality and best practices
  • Check for security concerns
  • Review SEO implementation approach
  • Provide comprehensive feedback

Review Summary

This PR implements a solid foundation for SEO optimization. The implementation follows good architectural patterns and addresses the stated requirements effectively.

✅ Strengths

Architecture & Code Quality:

  • Well-structured central configuration in frontend/src/lib/site.ts:1-53 - excellent single source of truth approach
  • Clean metadata implementation following Next.js best practices
  • Consistent typing with as const and proper TypeScript usage
  • Good separation of concerns between site config, env vars, and metadata

SEO Implementation:

  • Proper metadata hierarchy with template system in frontend/src/app/layout.tsx:18-20
  • Strategic noindex,follow on auth pages frontend/src/app/(auth)/*/page.tsx to avoid thin content indexing
  • Canonical URLs properly set across all pages
  • Good keyword targeting in frontend/src/lib/site.ts:35-44 aligned with retail intelligence domain

Environment Configuration:

  • Secure env var handling in frontend/src/env.ts:16 with proper validation and defaults
  • URL normalization with trailing slash removal in frontend/src/lib/site.ts:15

⚠️ Areas for Improvement

Code Quality:

  1. External script security concern in frontend/src/app/layout.tsx:41-45:

    <script
      async
      crossOrigin="anonymous" 
      src="https://tweakcn.com/live-preview.min.js"
    />

    Consider adding integrity hash for security or documenting why this external script is needed in production.

  2. Minor type safety - Consider making the absoluteUrl function more robust:

    export function absoluteUrl(path = '/'): string {
      return `${siteConfig.url}${path.startsWith('/') ? path : `/${path}`}`;
    }

    Could validate the path parameter or add JSDoc documentation.

SEO Optimization:

  1. Description lengths - Some descriptions are at the longer end:

    • Login: 142 chars (good)
    • Register: 143 chars (good)
    • Forgot password: 123 chars (good)
    • Consider staying closer to 120-140 char range for optimal display
  2. Keywords array usage - The keywords array in site config isn't used in individual page metadata, only in the root layout

🔍 Security Review

  • ✅ No hardcoded secrets or sensitive data
  • ✅ Environment variables properly validated
  • ✅ No obvious injection vulnerabilities
  • ⚠️ External script inclusion should be documented/secured

🧪 Test Coverage

  • ❌ No test coverage for the new site configuration utilities
  • Consider adding unit tests for absoluteUrl() function and site config validation
  • Integration tests for metadata generation would be valuable

📈 Performance Considerations

  • ✅ Minimal runtime overhead
  • ✅ Environment variable validation happens at build time
  • ✅ Site config is properly tree-shakeable

Recommendation: Approve with minor suggestions

This PR successfully implements the SEO foundation as described. The architecture is sound, implementation is clean, and it properly addresses the requirements. The external script concern is minor and the lack of tests, while not ideal, doesn't block this foundational change.

Great work on creating a maintainable, centralized SEO configuration system!


@prudentbird prudentbird self-assigned this Jun 5, 2026
@prudentbird prudentbird merged commit 7e19e70 into dev Jun 5, 2026
1 check passed
@prudentbird prudentbird deleted the feat/seo-105-page-titles-meta branch June 5, 2026 19:46
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.

feat(seo): optimize page titles and meta descriptions

1 participant