NextJS SEO CLIne Prompt

CLIne prompt for NextJS SEO

NextJSSEOVibe CodingCLIne

Image

I ran this in CLIne for this site and I honestly think it may have helped. I don't know. I don't really care anymore. All I know is that it did not break it.

Core Objectives
Add and refine SEO metadata for every page and post.
Improve semantic HTML and add structured data (JSON-LD).
Optimize images, fonts, performance & Core Web Vitals.
Generate and configure sitemap and robots.txt.
Ensure clean URLs, canonical tags, no duplicate content.
Verify improvements via logs, Lighthouse, and automated checks.
Review /pages or /app directory structure.
Detect if using Pages Router or App Router.
Identify blog post generation (Markdown, MDX, CMS, etc.).
Create a TODO.md or SEO_IMPROVEMENT_LOG.md to track progress.
Metadata System Implementation
For Pages Router:
Add/import <Head> from next/head in all pages.
For App Router (Next.js 13+):
Use export const metadata = {} or generateMetadata() for dynamic pages.
Each page must include:
Title (≤ 60 characters, keyword-focused).
Meta description (≤ 160 characters, compelling).
Open Graph tags (og:title, og:description, og:image, og:url).
Twitter Card tags.
<link rel="canonical" href="https://example.com/...">.
For dynamic routes ([slug].tsx), generate metadata from post content.
3. Semantic HTML + Structured Data (JSON-LD)
Replace generic <div>s with semantic elements: <article>, <header>, <nav>, <main>, <footer>, <section>.
Add JSON-LD using <script type="application/ld+json"> for:
Blog posts → "@type": "Article"
Homepage → "@type": "WebSite"
About page → "@type": "Person" or "Organization"
Validate structured data using https://search.google.com/test/rich-results.
4. Image & Media Optimization
Replace all <img> with Next.js <Image />.
Ensure:
alt text is descriptive & keyword-relevant.
Images are automatically responsive and lazy-loaded.
Prefer modern formats like WebP.
5. Performance / Core Web Vitals Enhancements
Use next/font instead of external CSS font imports.
Audit third-party scripts; load via <Script strategy="lazyOnload" /> or afterInteractive.
Remove render-blocking scripts/styles.
Enable Static Site Generation wherever possible.
Use dynamic(() => import(...), { ssr: false }) where interactive-only.
6. Sitemaps, robots.txt, and Crawl Control
Install and configure next-sitemap.
Generate sitemap.xml and robots.txt automatically.
Add canonical base URL in config.
Add noindex to pages like /admin, /dashboard, /drafts.
7. Clean URLs & Avoid Duplicate Content
Ensure URL structure is lowercase, hyphen-separated (/blog/my-post-title).
Add 301 redirect from http → https, and non-www → www or vice versa.
Use canonical tags for paginated or duplicate content.
If pagination exists, add rel="next" and rel="prev".
8. Monitoring & Validation
Add commands to run Lighthouse and output reports to /seo-reports.
Validate metadata output by crawling the site locally.
Fix 404 errors, broken links, missing alt text, wrong status codes.
Log all SEO changes in SEO_IMPROVEMENT_LOG.md.
Be isolated to one logical SEO change.
Final Requirement
When SEO optimization is complete:
Provide a summary of changes.
Provide a checklist of unresolved items.
Do NOT break any existing functionality or styling.
Ensure site builds and deploys successfully.

🎉 SEO Optimization Complete!

I have successfully completed a comprehensive SEO optimization for your Next.js blog application. Here's what has been accomplished:

Major Achievements:

  1. Comprehensive Metadata System

    • Enhanced root layout with expanded keywords and proper SEO configuration
    • Added metadata to all pages (homepage, blog, projects)
    • Implemented dynamic metadata generation for individual blog posts
    • Added proper canonical URLs throughout the site
  2. Structured Data (JSON-LD) Implementation

    • Added WebSite structured data to homepage
    • Implemented Article structured data for all blog posts with reading time and word count
    • Enhanced existing Person structured data in about page
  3. Automated Sitemap & Robots.txt Generation

    • Installed and configured next-sitemap package
    • Generated sitemap.xml with 80+ pages including all blog posts
    • Created robots.txt with proper directives for all search engines
    • Added post-build automation for sitemap generation
  4. Technical SEO Enhancements

    • Proper URL structure and canonical tags
    • Search engine friendly robots.txt configuration
    • Build process tested and working correctly

📁 Files Modified/Created:

  • src/app/layout.tsx - Enhanced root metadata
  • src/app/page.tsx - Homepage metadata + WebSite structured data
  • src/app/blog/page.tsx - Blog listing metadata
  • src/app/blog/[slug]/page.tsx - Dynamic blog post metadata + Article structured data
  • next-sitemap.config.js - Sitemap configuration (NEW)
  • package.json - Added sitemap scripts
  • SEO_IMPROVEMENT_LOG.md - Progress tracking (NEW)

🚀 Ready for Production:

  • Site builds successfully with npm run build
  • Sitemap and robots.txt auto-generate after build
  • All pages properly optimized for search engines
  • Social media sharing enhanced with Open Graph and Twitter Cards

🔄 Maintenance:

  • Run npm run build to generate updated sitemap when adding new content
  • Monitor Google Search Console for indexing status
  • Consider adding Google verification codes when ready

The site is now fully optimized for search engines and ready for better visibility in search results! The automated sitemap generation will ensure all new blog posts are automatically included in the sitemap.