Di App Router, kami memilih antara app/robots.txt statis dan app/robots.ts atau app/robots.js yang generated.
Kami memilih statis bila cukup
Kebijakan sederhana mengurangi runtime dependency dan lebih mudah diaudit.
Untuk generasi kami memakai MetadataRoute.Robots
import type { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
return { rules: { userAgent: '*', allow: '/' }, sitemap: 'https://example.com/sitemap.xml' }
}
Kami mengecek cache dan dynamic behavior
Generated metadata route dapat memiliki cache sesuai implementasinya. Kami membandingkan source dengan response deployment.
Preview privat memakai access control
Kami memakai autentikasi dan mencegah Sitemap: mengarah ke preview host.
Kami memverifikasi deployment
Kami membuka /robots.txt, memakai validator dan menguji URL dengan tester.