robot txtとは?意味や使い方を解説

robot.txt とは

目次

概要

robot.txt(ロボットドットテキスト)とは、ウェブボットやクローラーといった検索エンジンに対して、ウェブサイト内のクロール対象/非対象の指示を出すためのファイルのことである。

必要とされる理由

robot.txtを設置することで、意図しないページのクロールを防ぐことができる。また、クロールを許可するページを明示することで、検索エンジンに表示される陳腐化したコンテンツを回避することができる。

計算方法や定義

robot.txtは、ウェブサイトのルート(例:example.com/robot.txt)に置く必要がある。このファイルに記載する方法は、以下のようになる。

  • User-agent(クローラー名):どのクローラーに指示を出すかを指定するためのパラメータ。
  • Disallow(非対象指定のパス):クロールから除外するディレクトリやファイル名を指定するためのパラメータ。
  • Allow(対象指定のパス):クロールを許可するディレクトリやファイル名を指定するためのパラメータ。
  • Sitemap:サイトマップの場所を指定するためのパラメータ。

代表的な例を以下に示す。

User-agent: *
Disallow: /wp-admin/
Disallow: /cart/
Disallow: /checkout/
Disallow: /account/
Disallow: /my-account/
Sitemap: http://example.com/sitemap.xml

この例では、全てのクローラーに対して、/wp-admin/、/cart/、/checkout/、/account/、/my-account/以下のページをクロールしないように指定している。また、サイトマップの場所をhttp://example.com/sitemap.xmlに指定している。

具体例

以下に、robot.txtの具体例を示す。

Business Insider

Title: “What Is Robots.txt?”
Body: “The robots.txt file is a simple text file placed on your web server which tells web crawlers (like Googlebot) whether they should access a file or not. The robots.txt file is part of the the robots exclusion protocol (REP), a group of web standards that regulate how robots crawl the web, access and index content, and serve that content up to users.”

Ahrefs

Title: “How to Create an SEO-Boosting Robots.txt File in 5 Minutes (or Less)”
Body: “A robots.txt file tells search engine crawlers which pages or files the crawler can or can’t request from your site. This is used mainly to avoid overloading your site with requests; it is not a mechanism for keeping a web page out of Google.”

Moz

Title: “Robots.txt and Meta Robots: The Complete Guide”
Body: “The robots exclusion protocol (REP), or robots.txt, is a standard used by websites to communicate with web crawlers and other automated agents visiting the site. The REP standardizes how to inform the bots which areas of the website should not be processed or scanned.”

類語

  • robots.txt
  • クローラー制御ファイル
  • ロボットエクスクルージョンプロトコル
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次