DEV Community

Simplr
Simplr

Posted on • Originally published at blog.simplr.sh

Next.js 15 App Router SEO Comprehensive Checklist

This checklist is designed to guide you through setting up your Next.js project using the App Router for optimal SEO performance. It's broken down into categories for easier navigation and understanding.

I. Project Setup & Core Technical SEO

  • [ ] 1. Use Next.js 15 or Latest Stable Version:

    • Why: Newer versions often include performance improvements, bug fixes, and potentially new SEO-friendly features.
    • How: Ensure your package.json has the latest stable version of Next.js. Update using npm install next@latest or yarn add next@latest.
    • Learn More: Next.js Releases
  • [ ] 2. Server-Side Rendering (SSR) or Static Site Generation (SSG) Strategy:

    • Why: Next.js's SSR and SSG are foundational for SEO. Search engines can easily crawl and index fully rendered HTML content. Choose the appropriate strategy based on content dynamism. In the App Router, rendering is configured at the route segment level (folders). By default, Next.js App Router uses Server Components which are rendered on the server.
    • How:
    • SSG (Static Generation): By default, routes in the app directory are statically generated. You can explicitly configure static generation with revalidation or no revalidation.

      • No Revalidation (Pure SSG): Data is fetched at build time. Suitable for content that rarely changes.
      // app/page.tsx
      async function getData() {
        const res = await fetch('https://.../posts');
        return res.json();
      }
      
      export default async function Page() {
        const data = await getData();
        return <>{/* ... */}</>;
      }
      
      export const revalidate = false; // Optional: Explicitly set no revalidation
      
      • Revalidation (ISR - Incremental Static Regeneration): Data is fetched at build time and re-fetched in the background at intervals. Use revalidate route segment option.
      // app/page.tsx
      async function getData() {
        const res = await fetch('https://.../posts');
        return res.json();
      }
      
      export default async function Page() {
        const data = await getData();
        return <>{/* ... */}</>;
      }
      
      export const revalidate = 60; // Revalidate every 60 seconds
      
    • SSR (Server-Side Rendering): For dynamic content that needs to be updated on each request, ensure you are fetching data in your Server Components. By default, Server Components in the App Router are server-rendered. If you need to bypass the default static generation and ensure dynamic rendering on every request, you can use dynamic functions or route segment config options.

      // app/dashboard/page.tsx
      import { cookies } from 'next/headers';
      
      async function getUserData() {
        const cookieStore = cookies();
        const userId = cookieStore.get('userId')?.value;
        const res = await fetch(`https://.../user/${userId}`);
        return res.json();
      }
      
      export default async function Dashboard() {
        const userData = await getUserData();
        return <>{/* ... */}</>;
      }
      
      export const dynamic = 'force-dynamic'; // Opt-out of static generation, force dynamic rendering
      
    • Learn More: Data Fetching in Next.js App Router & Rendering in Next.js App Router

  • [ ] 3. Optimize robots.txt:

    • Why: Controls search engine crawler access to your site. Crucial for directing crawlers and preventing crawling of unimportant pages.
    • How:
    • Place robots.txt in your public directory for static robots.txt.
    • Dynamic robots.txt (Advanced): For environments (staging/production), create a server route to generate robots.txt dynamically using the App Router route handlers.

      // app/robots.txt/route.ts (Next.js App Router)
      import { NextResponse } from 'next/server';
      
      export async function GET() {
        const robotsContent = `
          User-agent: *
          Disallow: /staging-area/
          Allow: /
      
          Sitemap: https://www.yourdomain.com/sitemap.xml
        `;
        return new NextResponse(robotsContent, {
          headers: { 'Content-Type': 'text/plain' },
        });
      }
      
    • Learn More: robots.txt - Google Search Central

  • [ ] 4. Implement XML Sitemap (sitemap.xml):

    • Why: Helps search engines discover and index all important pages on your site, especially for large websites or newly launched sites.
    • How:
    • Static Sitemap: Generate sitemap.xml using libraries like next-sitemap or manually if your site is relatively static. Place it in your public directory.
    • Dynamic Sitemap (Recommended): Create a server route to generate sitemap.xml dynamically, fetching URLs from your database or CMS using App Router route handlers.

      // app/sitemap.xml/route.ts (Next.js App Router)
      import { getServerSideSitemap } from 'next-sitemap';
      // Note: Ensure you are using a version of next-sitemap compatible with App Router, or use alternative sitemap generation methods if needed.
      import { fetchPosts } from './utils/data-fetching'; // Example data fetching
      
      export async function GET() {
        const posts = await fetchPosts(); // Fetch your post data
        const fields = posts.map((post: any) => ({ // Assuming 'post' has a 'slug' property
          loc: `https://www.yourdomain.com/blog/${post.slug}`,
          lastmod: new Date().toISOString(), // Optional: Last modification date
        }));
      
        return getServerSideSitemap(fields);
      }
      
    • Learn More: Create and submit a sitemap - Google Search Central & next-sitemap

  • [ ] 5. Optimize URL Structure (Clean & Semantic URLs):

    • Why: Clear, readable URLs are user-friendly and SEO-friendly. They help search engines understand the page's content.
    • How:
    • Use hyphens (-) instead of underscores (_) or spaces.
    • Use lowercase letters.
    • Include relevant keywords.
    • Keep URLs concise and descriptive.
    • Example: /blog/nextjs-seo-checklist (Good) vs. /blog/post_id=123 (Bad)
    • Leverage Next.js App Router's folder structure and [slug] dynamic segments effectively.
    • Learn More: Use URL structure - Google Search Central
  • [ ] 6. Implement Canonical URLs:

    • Why: Prevents duplicate content issues, especially with URL parameters, pagination, or similar content accessible via different URLs.
    • How:
    • Use the <link rel="canonical" href="..."/> tag within the <head> element in your app/layout.tsx or directly in specific page.tsx components if canonical URLs vary.
    • Dynamically generate canonical URLs based on the current page's primary URL. Use usePathname and useSearchParams from next/navigation to construct the URL in Client Components if needed. For Server Components, you can access the request URL directly or pass relevant path information as props.

      // app/blog/[slug]/page.tsx (Example within a page component)
      import { usePathname, useSearchParams } from 'next/navigation';
      import Head from 'next/head';
      import { FunctionComponent } from 'react';
      
      interface BlogPostProps {
        post: any; // Replace 'any' with your actual post type
      }
      
      const BlogPost: FunctionComponent<BlogPostProps> = ({ post }) => {
        const pathname = usePathname(); // Use in Client Components
        const searchParams = useSearchParams(); // Use in Client Components
        const canonicalURL = `https://www.yourdomain.com${pathname}${searchParams ? `?${searchParams.toString()}` : ''}`; // Construct definitive URL
      
        return (
          <>
            <Head>
              <link rel="canonical" href={canonicalURL} />
              {/* ... other meta tags */}
            </Head>
            {/* ... page content */}
          </>
        );
      };
      
      export default BlogPost;
      
    • Learn More: Consolidate duplicate URLs - Google Search Central

  • [ ] 7. Ensure Mobile-Friendliness & Responsive Design:

    • Why: Mobile-first indexing is standard. Your site must be fully functional and visually appealing on mobile devices.
    • How:
    • Next.js is inherently responsive by default. Ensure your CSS and components are designed for various screen sizes.
    • Use viewport meta tag in <head> of your app/layout.tsx: <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    • Test responsiveness using browser developer tools and mobile testing tools.
    • Learn More: Mobile-friendly test - Google Search Central
  • [ ] 8. Website Performance Optimization (Speed is Key):

    • Why: Page speed is a significant ranking factor and crucial for user experience.
    • How:
    • Image Optimization: Use next/image component for optimized image delivery (resizing, lazy loading, formats like WebP).
    • Code Splitting: Next.js automatically code splits. Optimize component imports and lazy load components where possible, especially for Client Components.
    • Caching: Leverage Next.js's built-in caching mechanisms (data fetching cache, Route Handler cache, CDN).
    • Minimize JavaScript: Reduce unnecessary JavaScript in Client Components and optimize bundle sizes.
    • Optimize CSS: Minify and compress CSS. Remove unused CSS.
    • Choose a Fast Hosting Provider: Use a hosting solution optimized for Next.js (Vercel, Netlify, etc.).
    • Learn More: PageSpeed Insights - Google & Next.js Performance
  • [ ] 9. Implement HTTPS:

    • Why: Security is a ranking factor. HTTPS encrypts communication and builds user trust.
    • How:
    • Ensure your domain uses HTTPS. Most hosting providers offer free SSL certificates (Let's Encrypt).
    • Configure your hosting and CDN to enforce HTTPS.
    • Check for mixed content issues (loading HTTP resources on HTTPS pages).
    • Learn More: HTTPS as a ranking signal - Google Search Central
  • [ ] 10. Optimize for Core Web Vitals:

    • Why: Core Web Vitals (Largest Contentful Paint (LCP), First Input Delay (FID), Cumulative Layout Shift (CLS)) are crucial metrics for user experience and SEO ranking.
    • How:
    • LCP: Optimize image loading (use next/image), server response time, and rendering blocking resources.
    • FID: Minimize JavaScript execution time in Client Components, break up long tasks.
    • CLS: Reserve space for images and ads, avoid layout shifts caused by dynamically loaded content.
    • Use tools like PageSpeed Insights, Chrome DevTools, and Google Search Console to monitor and improve Core Web Vitals.
    • Learn More: Core Web Vitals - Google Search Central

II. On-Page SEO & Content Optimization

  • [ ] 11. Craft High-Quality, Relevant Content:

    • Why: Content is king! High-quality, unique, and valuable content is the foundation of SEO.
    • How:
    • Keyword Research: Identify relevant keywords your target audience uses. Use tools like Google Keyword Planner, Ahrefs, SEMrush, etc.
    • User Intent: Understand the search intent behind keywords and create content that satisfies that intent.
    • Unique & Original: Avoid duplicate content. Create original content that provides value.
    • Comprehensive & In-depth: Cover topics thoroughly. Aim to be the best resource for a given topic.
    • Readable & Engaging: Use clear language, headings, subheadings, bullet points, and visuals to make content easy to read and engaging.
    • Learn More: Create helpful, reliable, people-first content - Google Search Central
  • [ ] 12. Optimize Title Tags & Meta Descriptions:

    • Why: These are crucial for click-through rates (CTR) from search engine result pages (SERPs). They tell users and search engines what your page is about.
    • How:
    • Use the <Head> component from next/head to manage title and meta tags, typically placed in your app/layout.tsx or within specific page.tsx components for page-specific metadata.
    • Title Tags:
      • Keep them under 60 characters (including spaces).
      • Include primary keywords naturally.
      • Make them compelling and accurate to the page content.
      • Example: <title>Next.js SEO Checklist | Best Practices for Ranking in 2024</title>
    • Meta Descriptions:
      • Keep them under 160 characters (including spaces).
      • Write compelling and benefit-driven descriptions that encourage clicks.
      • Include relevant keywords and a call to action (optional).
      • Example: <meta name="description" content="A comprehensive Next.js SEO checklist for 2024. Learn best practices, technical setups, and content optimization strategies to improve your Next.js site's search engine rankings." />
    • Dynamic Titles & Descriptions: Generate them dynamically based on page content within your Server Components, especially for blog posts, product pages, etc.
    • Learn More: Create good titles and snippets in search results - Google Search Central & Meta descriptions - Google Search Central
  • [ ] 13. Optimize Header Tags (H1-H6):

    • Why: Header tags structure content and signal importance to search engines. H1 is typically the main topic, with H2-H6 for subheadings.
    • How:
    • Use H1 tag for the main heading of each page (usually page title).
    • Use H2-H6 tags to structure subtopics and sections logically.
    • Include relevant keywords in header tags naturally.
    • Maintain a hierarchical structure (H1 -> H2 -> H3, etc.).
    • Avoid using header tags solely for styling; use CSS for styling.
    • Example:

      <h1>Next.js SEO Checklist 2024</h1>
      <p>...</p>
      <h2>I. Technical SEO Setup</h2>
      <p>...</p>
      <h3>1. Project Setup</h3>
      <p>...</p>
      
    • Learn More: Use heading tags to emphasize important text - Google Search Central

  • [ ] 14. Image Optimization (Alt Text, File Names, Size):

    • Why: Images can improve user engagement and contribute to SEO. Optimized images load faster and are understandable by search engines.
    • How:
    • Alt Text: Provide descriptive alt text for all images. Describe the image contextually and include relevant keywords where appropriate. Example: <img src="/hero-image.jpg" alt="Next.js SEO Checklist for 2024 - Hero Image" />
    • File Names: Use descriptive file names with keywords (e.g., nextjs-seo-checklist-2024.jpg instead of image123.jpg).
    • Image Size & Compression: Optimize image file sizes for the web using tools like TinyPNG, ImageOptim, or next/image. Use appropriate image formats (WebP, JPEG, PNG).
    • next/image Component: Utilize next/image for automatic image optimization, lazy loading, and responsive images.
    • Learn More: Image SEO - Google Search Central & next/image Documentation
  • [ ] 15. Internal Linking Strategy:

    • Why: Internal links help search engines discover and understand the structure of your website. They also distribute link equity (link juice) and improve user navigation.
    • How:
    • Link relevant pages within your website to each other.
    • Use descriptive anchor text (the clickable text of the link) that includes relevant keywords.
    • Create a logical site structure and navigation using the folder structure in the app directory.
    • Use Next.js <Link> component from next/link for client-side navigation and SEO-friendly links.
    • Example: <Link href="/blog/another-relevant-post">Read more about internal linking best practices</Link>
    • Learn More: Internal links - Google Search Central
  • [ ] 16. Structured Data Markup (Schema.org):

    • Why: Structured data helps search engines understand the content of your pages more deeply. It can enable rich results in SERPs (e.g., review stars, FAQs, event listings), improving visibility and CTR.
    • How:
    • Implement structured data using JSON-LD format (recommended by Google).
    • Use Schema.org vocabulary to markup different types of content (Articles, Products, Events, FAQs, Recipes, etc.).
    • Test your structured data using Google's Rich Results Test tool.
    • Example (Article schema) - Place this within your page.tsx component:

      ```tsx
      import Head from 'next/head';
      import { FunctionComponent } from 'react';
      
      interface BlogPostProps {
        post: any; // Replace 'any' with your actual post type
      }
      
      const BlogPost: FunctionComponent<BlogPostProps> = ({ post }) => {
        return (
          <>
            <Head>
              <script type="application/ld+json">
                {JSON.stringify({
                  "@context": "https://schema.org",
                  "@type": "Article",
                  "mainEntityOfPage": {
                    "@type": "WebPage",
                    "@id": `https://www.yourdomain.com/blog/${post.slug}`
                  },
                  "headline": post.title,
                  "image": [
                    "https://www.yourdomain.com/images/blog-thumbnail.jpg"
                   ],
                  "datePublished": "2024-01-20T08:00:00+08:00",
                  "dateModified": "2024-01-25T09:20:00+08:00",
                  "author": {
                    "@type": "Person",
                    "name": "Your Name"
                  },
                  "publisher": {
                    "@type": "Organization",
                    "name": "Your Website Name",
                    "logo": {
                      "@type": "ImageObject",
                      "url": "https://www.yourdomain.com/logo.png"
                    }
                  },
                  "description": post.excerpt
                })}
              </script>
              {/* ... rest of Head and page content */}
            </Head>
            {/* ... page content */}
          </>
        );
      };
      
      export default BlogPost;
      ```
      
    • Learn More: Understand how structured data works - Google Search Central & Schema.org & Rich Results Test - Google

  • [ ] 17. Optimize for Local SEO (If Applicable):

    • Why: If your business targets a local audience, local SEO is crucial for ranking in local search results and Google Maps.
    • How:
    • Google Business Profile (GBP): Claim and optimize your GBP listing. Ensure NAP (Name, Address, Phone Number) consistency.
    • Local Citations: List your business in relevant online directories.
    • Local Schema Markup: Use LocalBusiness schema markup.
    • Location Pages: Create dedicated pages for each location if you have multiple, using dynamic routes in the app directory.
    • Local Keywords: Target local keywords in your content.
    • Reviews: Encourage customer reviews on Google and other platforms.
    • Learn More: Local SEO - Google Business Profile Help

III. Advanced Next.js & SEO Considerations

  • [ ] 18. Leverage Next.js Middleware for SEO Redirects & Rewrites:

    • Why: Middleware allows you to execute code before a request is completed. Useful for implementing redirects (301, 302) for SEO purposes (e.g., moving pages, fixing broken URLs) and URL rewrites.
    • How:
    • Create a middleware.ts file in your app directory.
    • Example redirect in middleware:

      // middleware.ts
      import { NextResponse } from 'next/server';
      import { NextRequest } from 'next/server';
      
      export function middleware(request: NextRequest) {
        const url = request.nextUrl.pathname;
      
        if (url === '/old-page') {
          return NextResponse.redirect(new URL('/new-page', request.url), 301); // 301 for permanent redirect
        }
        return NextResponse.next();
      }
      
      export const config = {
        matcher: ['/old-page'], // Apply middleware to /old-page only
      };
      
    • Learn More: Next.js Middleware

  • [ ] 19. Handle 404 Pages Effectively:

    • Why: Custom 404 pages improve user experience when users land on non-existent pages. SEO-wise, ensure they correctly return a 404 status code and guide users back to your site.
    • How:
    • Create a not-found.tsx file at the root of your app directory or within specific route segments to customize 404 pages for different sections.
    • Customize the not-found.tsx page to be user-friendly and helpful, with links to your homepage or other important pages.
    • Next.js App Router automatically handles 404 status codes when using notFound() function or not-found.tsx page.
    • Learn More: Not Found Page - Next.js App Router
  • [ ] 20. Consider Internationalization (i18n) for Multi-Language Sites:

    • Why: If you target multiple regions and languages, i18n is essential for reaching a global audience. Proper i18n setup is crucial for SEO in multiple languages.
    • How:
    • Use Next.js's i18n routing features (subpath routing, domain routing) configured in next.config.js.
    • Implement hreflang tags to tell search engines about language and regional targeting of your pages. Place these tags within the <head> of your app/layout.tsx or specific page.tsx components.
    • Translate content accurately and localize for each target audience.
    • Example hreflang tags in <Head> within app/layout.tsx:

      ```tsx
      <link rel="alternate" href="https://www.yourdomain.com/en/" hreflang="en" />
      <link rel="alternate" href="https://www.yourdomain.com/es/" hreflang="es" />
      <link rel="alternate" href="https://www.yourdomain.com/fr/" hreflang="fr" />
      <link rel="alternate" href="https://www.yourdomain.com/" hreflang="x-default" />
      ```
      
    • Learn More: Internationalized Routing - Next.js & Tell Google about localized versions of your page - Google Search Central

  • [ ] 21. Monitor & Analyze SEO Performance:

    • Why: SEO is an ongoing process. Monitoring performance and analyzing data is crucial for identifying areas for improvement and tracking progress.
    • How:
    • Google Search Console: Set up and regularly monitor your site in Google Search Console. Track indexing status, crawl errors, search performance, Core Web Vitals, and security issues.
    • Google Analytics: Use Google Analytics to track website traffic, user behavior, and conversions.
    • Keyword Rank Tracking Tools: Use tools like SEMrush, Ahrefs, or Rank Math to track your keyword rankings.
    • Regular SEO Audits: Conduct periodic SEO audits to identify technical SEO issues, content gaps, and areas for optimization.
    • Learn More: Google Search Console & Google Analytics

IV. Accessibility & User Experience (Indirect SEO Benefits)

  • [ ] 22. Ensure Website Accessibility (WCAG Guidelines):

    • Why: Accessibility is not directly a ranking factor, but it significantly impacts user experience. A more accessible website is often more user-friendly, leading to better engagement metrics, which can indirectly benefit SEO.
    • How:
    • Follow WCAG (Web Content Accessibility Guidelines) standards.
    • Use semantic HTML in your components.
    • Provide alt text for images using next/image component.
    • Ensure sufficient color contrast.
    • Keyboard navigation.
    • Screen reader compatibility.
    • Use accessibility testing tools (e.g., WAVE, Axe).
    • Learn More: WCAG - Web Accessibility Initiative (WAI) & Accessibility in Next.js
  • [ ] 23. Optimize User Experience (UX):

    • Why: UX is crucial for engagement, time on site, and reduced bounce rates. Positive UX signals can indirectly improve SEO.
    • How:
    • Site Navigation: Make navigation clear and intuitive, leveraging the App Router's folder structure for logical organization.
    • Page Layout: Use clear layouts and visual hierarchy in your components.
    • Content Readability: Use readable fonts, spacing, and formatting.
    • Fast Loading Times: Optimize performance (see point #8).
    • Engaging Content: Create content that keeps users interested and encourages interaction.
    • Learn More: User experience (UX) signals - Google Search Central

V. Post-Launch & Ongoing SEO

  • [ ] 24. Submit Sitemap to Search Engines:

  • [ ] 25. Build High-Quality Backlinks (Off-Page SEO):

    • Why: Backlinks from reputable websites are still a significant ranking factor.
    • How:
    • Content Marketing: Create valuable content that other sites will want to link to.
    • Guest Blogging: Write guest posts for relevant websites in your niche.
    • Outreach: Reach out to relevant websites and influencers to promote your content.
    • Broken Link Building: Find broken links on other sites and suggest your content as a replacement.
    • Earned Links: Focus on naturally earning links by creating exceptional content and building relationships.
    • Note: Off-page SEO is beyond Next.js-specific setup, but crucial for overall SEO success.
    • Learn More: Link schemes - Google Search Central & Build high-quality sites - Google Search Central
  • [ ] 26. Regularly Update Content:

    • Why: Fresh content signals to search engines that your website is active and relevant. Updating content can also improve rankings for existing keywords.
    • How:
    • Keep your content up-to-date and accurate.
    • Refresh old blog posts with new information or expanded content.
    • Add new content regularly (blog posts, case studies, guides, etc.).
  • [ ] 27. Stay Updated with SEO Best Practices & Algorithm Updates:

    • Why: SEO is constantly evolving. Search engine algorithms change, and best practices evolve. Staying informed is crucial for maintaining and improving your SEO performance.
    • How:
    • Follow reputable SEO blogs and resources (e.g., Google Search Central Blog, Moz Blog, Search Engine Journal, Ahrefs Blog).
    • Monitor industry news and updates.
    • Adapt your SEO strategy as needed based on algorithm changes and new best practices.

Using this Checklist:

  • Go through each item in the checklist.
  • Tick the boxes as you implement each step in your Next.js project.
  • Use the provided links to learn more about each topic.
  • This checklist is a starting point; you may need to adapt it based on the specific needs of your project and industry using the App Router.

By diligently following this checklist, you'll set your Next.js project using the App Router on a strong SEO foundation, maximizing its potential for high search engine rankings and organic traffic. Remember that SEO is a long-term strategy, and consistent effort is key to achieving sustainable results. Good luck!

Top comments (0)