robots.ts

robots.ts

基本信息

  • 类型: Next.js API 路由 (Server Component)
  • 路径: ./src/app/robots.ts

功能描述

动态生成 robots.txt 文件,指导搜索引擎爬虫如何抓取网站内容。

路由

  • 路径: /robots.txt
  • 参数: 无

依赖导入

  • next - MetadataRoute 类型

主要功能

  • 允许所有搜索引擎爬虫访问
  • 禁止爬取 API 路由
  • 禁止爬取管理后台
  • 禁止爬取用户设置页面
  • 禁止爬取登录/注册页面
  • 提供站点地图 URL

SEO

  • 规则:

- UserAgent: * (所有爬虫) - Allow: / (允许根路径) - Disallow: /api/, /admin/, /settings/, /login, /register - Sitemap: ${baseUrl}/sitemap.xml

← 返回目录