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 Variable | Type | Default |
|---|---|---|
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:
/** @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.xmlandpublic/robots.txt.
Set Up robots.txt
- The
robots.txtfile is generated bynext-sitemap. Customize it innext-sitemap.config.jsto control crawler access:
robotsTxtOptions: {
policies: [
{ userAgent: '*', allow: '/' },
{ userAgent: '*', disallow: '/private/*' },
],
}Verify Configuration
- Run
npm run devto test locally and check NEXT_PUBLIC_SITE_URL validation. - After deployment, verify
sitemap.xmlandrobots.txtathttps://yourapp.com/sitemap.xmlandhttps://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
Overview
Learn how to rank higher on Google with pre-configured sitemaps, metadata, and page speed optimizations.
Customization & Optimization
Learn how to customize metadata, optimize page speed, and extending SEO features in Plainform. It includes code snippets to help users tailor SEO to their project’s needs.