# robots.txt の書き方
robots.txt は、ウェブサイトにアクセスする検索エンジンのクローラー(ロボット)がどのページやファイルをクロールできるかを指定するためのテキストファイルです。robots.txt の設定は強制的なものではなく、指定を行っても検索してしまう検索エンジンもある可能性があります。
# robots.txt の役割
- クロールの最適化を行う
- 公開しないページのインデックス登録を防ぐ
- 重要なコンテンツを優先的にクロールさせる
# 基本構造
User-agent: [クローラー名]
Disallow: [アクセス禁止にするパス]
Allow: [アクセスを許可するパス]
| 記述例 | 説明 |
|---|---|
User-agent: * | すべてのクローラ |
User-agent: Googlebot | |
User-agent: bingbot | Bing |
User-agent: baidu | 百度(バイドゥ) |
# よく使われる例
User-agent: *
Disallow: /admin/
Disallow: /search/
Disallow: /*.webm
Disallow: /*.mp4
Disallow: /*.wmv
Disallow なしになっているので、すべてのサイトを許可するようになります。
# Youtube の robots.txt
# robots.txt file for YouTube
# Created in the distant future (the year 2000) after
# the robotic uprising of the mid 90's which wiped out all humans.
User-agent: Mediapartners-Google*
Disallow:
User-agent: *
Disallow: /api/
Disallow: /comment
Disallow: /feeds/videos.xml
Disallow: /get_video
Disallow: /get_video_info
Disallow: /get_midroll_info
Disallow: /live_chat
Disallow: /login
Disallow: /qr
Disallow: /results
Disallow: /signup
Disallow: /t/terms
Disallow: /timedtext_video
Disallow: /verify_age
Disallow: /watch_ajax
Disallow: /watch_fragments_ajax
Disallow: /watch_popup
Disallow: /watch_queue_ajax
Disallow: /youtubei/
Sitemap: https://www.youtube.com/sitemaps/sitemap.xml
Sitemap: https://www.youtube.com/product/sitemap.xml