2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sitemap.xmlとは

sitemap.xmlをサーバ上に置くことで、クローラーを呼び、検索エンジンがインデックスしやすいようにしてあげる。

つくってみる

タグの種類

<?xml version=’1.0′ encoding=’UTF-8′?>
<urlset> 【必須】 全体を囲むタグで、現在のプロトコル標準を参照。 
<url>    【必須】 各URLエントリの親タグ。その他のタグを囲むだけのタグ。 
<loc>    【必須】 ページのURLを記述。末尾にスラッシュを含める必要があり、 値は 2,048 文字以下で指定する必要がある。 </loc>
<lastmod>    【オプション】 ファイルの最終更新日。 </lastmod>
<changefreq> 【オプション】 ページの更新頻度。 </changefreq>
<priority>   【オプション】 URL の優先度。0.0 から 1.0 までの値が指定できる。デフォルトは0.5。
                  サイト内のすべての URL に高い優先度を設定しない。 
</priority>
</url>
</urlset>

ページ更新頻度(changefreq)一覧

  • always アクセスするたびに内容が更新される
  • hourly 1 時間に 1 回以下
  • daily 1 日に 1 回以上
  • weekly 1 週に 1 回以上
  • monthly 1 月に 1 回以上
  • yearly 1 年に 1 回以上
  • never 定期的にクロールされる(更新しなくてもいいページ)

ファイルを置く場所

sitemap.xmlはルートディレクトリに置く。

複数のサイトマップファイルを使用する場合

50,000URL以上になると複数のサイトマップが必要になる。その場合は、サイトマップインデックスファイルを作成し、サイトマップが複数あることをクローラーに知らせる。

<?xml version=’1.0′ encoding=’UTF-8′?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc> 【必須】 1つ目のサイトマップファイル名</loc>
      <lastmod> 【オプション】 ファイルの最終更新日</lastmod>
   </sitemap>
   <sitemap>
      <loc> 【必須】 2つ目のサイトマップファイル名</loc>
      <lastmod> 【オプション】 ファイルの最終更新日</lastmod>
   </sitemap>
</sitemapindex>

指定URLを除外

robots.txt 

クローラーにアクセス制限するためのファイル。アクセス制限する理由として2つ

  • クローラーは内部リンクや被リンクを辿ってやってくること。サイト内で多くのリンクを獲得しているページには、クローラーも多く訪れてしまう。
  • ドメインごとにクローラーが訪問するページ数には限りがあること。限られた中で、重要なページに多くクロールしてもらいたい。
User-agent: クローラー名
Disallow: /アクセス拒否したいディレクトリ名/

注意点

  • ユーザーはrobots.txtを閲覧できる
  • 重複コンテンツにはrobots.txtを使用せず、URL正規化対応

動作確認する

Google Search Consoleは、Google 検索結果でのサイトのパフォーマンスを監視、管理できる Google の無料サービス。Google にどのように認識されるかを確認し、検索結果でのサイトのパフォーマンスを最適化できるようになる。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?