静的サイトジェネレーターでのrobots.txt設定
Hugo・Gatsby・AstroなどのSSGでは、各フレームワーク固有の方法でrobots.txtを設定する必要があります。
Hugoでの設定方法
Hugoでは static/robots.txt にファイルを配置します:
# static/robots.txt
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: PerplexityBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: CCBot
Disallow: /
User-agent: Diffbot
Disallow: /
User-agent: Bytespider
Disallow: /
User-agent: OAI-SearchBot
Disallow: /
User-agent: anthropic-ai
Disallow: /
User-agent: Amazonbot
Disallow: /
User-agent: YouBot
Disallow: /
User-agent: cohere-ai
Disallow: /
User-agent: MistralBot
Disallow: /
User-agent: *
Allow: /
または hugo.toml でテンプレートから生成する方法:
# hugo.toml
enableRobotsTXT = true
{{/* layouts/robots.txt */}}
User-agent: GPTBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
{{/* ... 他のAIボット ... */}}
User-agent: *
Allow: /
Sitemap: {{ .Site.BaseURL }}sitemap.xml
Gatsbyでの設定方法
Gatsbyでは static/robots.txt を使うか、gatsby-plugin-robots-txt プラグインを使います:
# npmでインストール
npm install gatsby-plugin-robots-txt
# gatsby-config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-robots-txt',
options: {
policy: [
{ userAgent: 'GPTBot', disallow: '/' },
{ userAgent: 'ClaudeBot', disallow: '/' },
{ userAgent: 'PerplexityBot', disallow: '/' },
{ userAgent: 'Google-Extended', disallow: '/' },
{ userAgent: 'CCBot', disallow: '/' },
{ userAgent: 'Diffbot', disallow: '/' },
{ userAgent: 'Bytespider', disallow: '/' },
{ userAgent: 'Amazonbot', disallow: '/' },
{ userAgent: 'OAI-SearchBot', disallow: '/' },
{ userAgent: 'anthropic-ai', disallow: '/' },
{ userAgent: 'YouBot', disallow: '/' },
{ userAgent: 'cohere-ai', disallow: '/' },
{ userAgent: 'MistralBot', disallow: '/' },
{ userAgent: '*', allow: '/' },
]
}
}
]
}
Astroでの設定方法
# public/robots.txt として配置
# または @astrojs/sitemap と合わせて設定
# astro.config.mjs に robotsTxt の設定は組み込みではないため
# public/robots.txt に直接記述するのが最も確実
Vercel・Netlifyにデプロイしている場合
これらのプラットフォームにデプロイする場合、生成されたrobots.txtが正しく配信されているか確認してください:
curl https://yoursite.com/robots.txt | grep GPTBot
設定後の実際のAIボットアクセスは、AI Access Monitorで継続監視できます。