3.

sitemap.xmlのエラー対処|namespace不正・XMLパース失敗・URL not allowed

編集
この記事の要点
  • Incorrect namespace: xmlns が http://www.sitemaps.org/schemas/sitemap/0.9 でない
  • unable to parse XML: 不正な文字、未閉じタグ、BOM 付き UTF-8 / 別エンコーディング
  • URL not allowed: sitemap のドメインと記載 URL のドメイン / プロトコルが不一致
  • Sitemap index too large: 1 ファイル 50,000 URL / 50 MB(非圧縮)上限。超えたら index 分割
  • Content-Type: application/xml or text/xml、gzip なら application/gzip

sitemap.xml の標準フォーマット

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-06-10</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
</urlset>

エラー一覧

エラー原因対処
Incorrect namespacexmlns 誤り正しい URI に修正
unable to parse XML構文エラー / BOM / 文字化けUTF-8 (BOM無)、タグ閉じ
Empty sitemap<url> が 0 個URL を 1 つ以上
URL not allowedドメイン / プロトコル不一致sitemap と同 host に
Tag mismatch未閉じ / 重複 タグXML Linter で検出
Sitemap index too large50,000 URL / 50MB 超index 分割
Invalid XML: too many tagsタグ重複1 url 内に loc は 1 個
Invalid datelastmod 形式エラーISO 8601 (YYYY-MM-DD)
Compression errorgzip ヘッダ無しContent-Encoding 設定
HTTP 404 / 500そもそも sitemap.xml に到達できないパス / 権限確認

1. Incorrect namespace

<!-- ❌ NG: タイポ -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.90">

<!-- ❌ NG: URL 違う -->
<urlset xmlns="http://sitemaps.org/sitemap/0.9">

<!-- ✅ OK -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

画像 / 動画 / ニュース sitemap は追加 namespace が必要:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
  <url>
    <loc>https://example.com/post/1</loc>
    <image:image>
      <image:loc>https://example.com/img/1.jpg</image:loc>
    </image:image>
  </url>
</urlset>

2. Unable to parse XML

XML として読めない。よくある原因と検出方法:

原因確認
BOM 付き UTF-8head -c 3 sitemap.xml | xxd → ef bb bf
Shift_JIS / EUC-JPfile sitemap.xml
未エスケープの &, <amp ; → & に
未閉じタグxmllint --noout sitemap.xml
制御文字cat -v で表示
# 検証
xmllint --noout sitemap.xml
# OK なら何も出ない、NG なら行番号付きでエラー

# Schema 検証
curl -O https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
xmllint --schema sitemap.xsd --noout sitemap.xml

# BOM 削除(Linux/macOS)
sed -i '1s/^\xEF\xBB\xBF//' sitemap.xml

# Windows PowerShell で BOM 無し UTF-8 で出力
Get-Content sitemap.xml | Out-File -Encoding UTF8NoBOM sitemap.xml

3. URL not allowed

sitemap.xml に書かれた URL のドメインが、sitemap 自体のドメインと違う場合に出ます:

<!-- https://example.com/sitemap.xml が以下を含む場合 -->

<!-- ❌ NG: 別ドメイン -->
<loc>https://anotherdomain.com/page</loc>

<!-- ❌ NG: www の有無不一致 -->
<loc>http://www.example.com/page</loc>
<!-- → sitemap が https://example.com にあるなら URL も https://example.com/ に -->

<!-- ❌ NG: プロトコル不一致 -->
<loc>http://example.com/page</loc>
<!-- → HTTPS で配信しているなら HTTPS の URL に -->

<!-- ✅ OK -->
<loc>https://example.com/page</loc>

4. Sitemap index too large

1 sitemap には50,000 URL まで / 非圧縮で 50 MB まで。超えるなら sitemap index で分割:

<!-- sitemap_index.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-posts-1.xml</loc>
    <lastmod>2026-06-10</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-posts-2.xml</loc>
    <lastmod>2026-06-10</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-products.xml</loc>
    <lastmod>2026-06-10</lastmod>
  </sitemap>
</sitemapindex>

5. lastmod の形式

<!-- ✅ OK: ISO 8601 -->
<lastmod>2026-06-10</lastmod>
<lastmod>2026-06-10T12:34:56+09:00</lastmod>
<lastmod>2026-06-10T12:34:56Z</lastmod>

<!-- ❌ NG: 日本独自形式 -->
<lastmod>2026/06/10</lastmod>
<lastmod>令和8年6月10日</lastmod>

6. Content-Type / gzip 圧縮

# nginx
location = /sitemap.xml {
    types { application/xml xml; }
    default_type application/xml;
}

location = /sitemap.xml.gz {
    types { application/gzip gz; }
    default_type application/gzip;
    add_header Content-Encoding gzip;
}
# Apache .htaccess
AddType application/xml .xml
AddType application/gzip .gz

# gzip 配信の Content-Encoding 自動付与
<Files "sitemap.xml.gz">
  Header set Content-Encoding "gzip"
</Files>

7. Google Search Console での確認

  1. Search Console → 該当プロパティ → サイトマップ
  2. 新規 sitemap を追加 (例: sitemap.xml)
  3. ステータスを確認: 「成功」 / 「取得できませんでした」 / 「エラー」
  4. エラー内容を展開して該当 URL を確認

「取得できませんでした」はrobots.txt で sitemap を disallow していることが原因のことが多い。

# robots.txt
User-agent: *
Disallow: /admin/

# sitemap.xml は allow されている必要あり
Sitemap: https://example.com/sitemap.xml

8. IIS で Content-Type が正しくない

<!-- web.config -->
<configuration>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".xml" />
      <mimeMap fileExtension=".xml" mimeType="application/xml" />
      <remove fileExtension=".gz" />
      <mimeMap fileExtension=".gz" mimeType="application/gzip" />
    </staticContent>
  </system.webServer>
</configuration>

FAQ

Q: sitemap.xml は必須?
A: 必須ではないが、新規サイト / 動的に増えるサイト / リダイレクト多いサイトでは強く推奨。Google にクロールヒントを渡せる。

Q: sitemap を更新したら Google にすぐ反映される?
A: いいえ。クロール優先度はクロール頻度・サイトの権威性に依存。Search Console から「再送信」できますが即時反映ではない。

Q: prioritychangefreq は意味ある?
A: Google はほぼ無視すると公式表明。lastmod は読まれる。priority/changefreq は省略してよい。

編集
Post Share
子ページ
  1. Incorrect namespace. Your Sitemap or Sitemap index file does
同階層のページ
  1. サイトマップの書き方
  2. サイトマップインデックスの書き方
  3. エラー一覧 (sitemap.xml)

最近更新/作成されたページ