Configuration & Best Practices

Learn how to configure SEO settings like sitemaps, robots.txt, and metadata in Plainform, along with best practices to maintain optimal SEO performance.

To use Resend, you must configure the RESEND_API_KEY and RESEND_AUDIENCE_ID in your .env file, validated by t3-env, and set up DNS records for reliable email delivery. The Resend client is initialized in lib/resend to enable email sending and audience management.

Steps to Configure SEO

Set Up Environment Variables

  • Add your site’s URL to your .env (or .env.local) file for sitemap and metadata:
Env VariableTypeDefault
SITE_URL?
string
http://localhost:3000
NEXT_PUBLIC_SITE_URL?
string
http://localhost:3000
  • Ensure .env is listed in .gitignore, and validate with t3-env (in env.mjs).

Configure next-sitemap

  • Plainform includes next-sitemap for automatic sitemap generation. Check next-sitemap.config.js:
next-sitemap.config.ts
/** @type {import('next-sitemap').IConfig} */
module.exports = {
  siteUrl: process.env.NEXT_PUBLIC_SITE_URL || 'https://yourapp.com',
  generateRobotsTxt: true,
  exclude: ['/server-sitemap.xml'],
};
  • Run npm run build to generate public/sitemap.xml and public/robots.txt.

Set Up robots.txt

  • The robots.txt file is generated by next-sitemap. Customize it in next-sitemap.config.js to control crawler access:
next-sitemap.config.ts
robotsTxtOptions: {
  policies: [
    { userAgent: '*', allow: '/' },
    { userAgent: '*', disallow: '/private/*' },
  ],
}

Verify Configuration

  • Run npm run dev to test locally and check NEXT_PUBLIC_SITE_URL validation.
  • After deployment, verify sitemap.xml and robots.txt at https://yourapp.com/sitemap.xml and https://yourapp.com/robots.txt.
  • Use tools like Google Search Console to submit your sitemap and monitor crawl issues

Best Practices for SEO

  • Metadata Consistency: Ensure every page has unique, descriptive <title> and <meta name="description"> tags.
  • Image Optimization: Use Next.js <Image/> component for lazy loading and automatic resizing.
  • Minimize JavaScript: Keep client-side JavaScript minimal to maintain fast load times.
  • Mobile-Friendly Design: Ensure responsive layouts for mobile SEO.
  • Clean URLs: Use descriptive, keyword-rich URLs in app routes (e.g., /blog/post-title).

For advanced configurations, consult the Next.js` Documentation and next-sitemap Documentation.

How is this guide ?

Last updated on