この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:6
ページ更新者:atom
更新日時:2026-06-11 07:29:05

タイトル: Incorrect namespace. Your Sitemap or Sitemap index file does
SEOタイトル: XML サイトマップ「Incorrect namespace」エラーの原因と対処

この記事の要点
  • Google Search Console でのエラー "Incorrect namespace. Your Sitemap or Sitemap index file does not properly declare the namespace"
  • 主原因: xmlns 属性の URL 誤り、または <urlset><sitemapindex> の混同
  • 正しい名前空間: xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" (URL 末尾スラッシュ無し、http で OK)
  • BOM 付き UTF-8 / XML 宣言抜け / CDATA 誤用も同エラーの原因
  • 検証: xmllint --noout sitemap.xml + 公式 XSD でスキーマ検証

エラー全文と発生場所

Google Search Console → サイトマップ → エラー詳細

[エラーメッセージ]
Incorrect namespace.
Your Sitemap or Sitemap index file does not properly declare the namespace.

[該当ファイル]
https://example.com/sitemap.xml

[影響]
- 検索エンジンがサイトマップを処理できない
- 含まれる URL が新規発見対象から外れる
- 既存インデックス済 URL の更新検知が遅れる可能性

原因 1: xmlns 属性が間違っている

最頻出原因。xmlns の値は厳密に指定する必要があります:

<!-- ❌ NG: 末尾スラッシュあり -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9/">

<!-- ❌ NG: バージョン違い -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.8">

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

<!-- ❌ NG: https://  (※ Google は許容するが正式仕様は http://) -->
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
<!-- これでも動くがエラー報告されるケースあり -->

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

原因 2: urlset と sitemapindex の混同

ファイル種別ルート要素子要素
個別サイトマップ<urlset><url> / <loc>
サイトマップインデックス<sitemapindex><sitemap> / <loc>
<!-- ❌ NG: インデックスなのに urlset を使っている -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-1.xml</loc>
  </sitemap>
</urlset>

<!-- ✅ OK -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-1.xml</loc>
  </sitemap>
</sitemapindex>

<!-- ❌ NG: 個別なのに sitemapindex を使っている -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/page1</loc>
  </url>
</sitemapindex>

<!-- ✅ OK -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/page1</loc>
  </url>
</urlset>

原因 3: XML 宣言が無い

<!-- ❌ NG: 1 行目が直接 <urlset> -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  ...
</urlset>

<!-- ✅ OK: XML 宣言を先頭に -->
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  ...
</urlset>

厳密には XML 宣言が無くてもパーサは動きますが、encoding が UTF-8 でない判定になるとエラー報告されます。必ず付ける習慣を。

原因 4: BOM 付き UTF-8 で保存している

Windows のメモ帳や一部エディタは UTF-8 ファイルの先頭に BOM (Byte Order Mark, EF BB BF の 3 バイト) を付けます。XML 宣言より前にバイトがあると、パーサが名前空間を含む先頭部分を正しく読めません:

# BOM の有無を確認
hexdump -C sitemap.xml | head -1
# 00000000  ef bb bf 3c 3f 78 6d 6c  20 76 65 72 73 69 6f 6e  |...<?xml version|
#  ↑ EF BB BF が BOM。これがあると NG

# BOM 除去 (sed 経由)
sed -i '1s/^\xEF\xBB\xBF//' sitemap.xml

# 確認
hexdump -C sitemap.xml | head -1
# 00000000  3c 3f 78 6d 6c 20 76 65  72 73 69 6f 6e 3d 22 31  |<?xml version="1|

# PowerShell でも可
# (Get-Content sitemap.xml -Raw -Encoding UTF8) |
#   Set-Content sitemap.xml -Encoding utf8NoBOM   # PowerShell 6+

Visual Studio Code は右下にエンコーディング表示があるので、UTF-8 without BOM で保存しなおせます。

原因 5: CDATA を不要な箇所で使用

<!-- ❌ NG: CDATA の前後にスペースや何かがあると壊れる -->
<urlset xmlns="<![CDATA[http://www.sitemaps.org/schemas/sitemap/0.9]]>">

<!-- ❌ NG: loc 内で URL の一部だけ CDATA -->
<loc>https://example.com/<![CDATA[page?id=1&type=a]]></loc>

<!-- ✅ OK: 普通に書く + & は & にエスケープ -->
<loc>https://example.com/page?id=1&type=a</loc>

原因 6: 不要な追加 xmlns で名前空間が混乱

<!-- ❌ NG: prefix なしの xmlns を複数指定 -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns="http://www.google.com/schemas/sitemap-image/1.1">
  ...
</urlset>

<!-- ✅ OK: 拡張は別 prefix で -->
<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">
  <url>
    <loc>https://example.com/photo.jpg</loc>
    <image:image>
      <image:loc>https://example.com/photo.jpg</image:loc>
    </image:image>
  </url>
</urlset>

デバッグの手順

  1. ブラウザで直接開く: view-source: プレフィックスで XML 整形表示
  2. xmllint で構文チェック:
# Linux / Mac
xmllint --noout sitemap.xml
# OK なら何も出ない
# NG なら行番号付きエラー

# Schema 検証 (公式 XSD と照合)
curl -s -o sitemap.xsd https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
curl -s -o siteindex.xsd https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd

xmllint --schema sitemap.xsd sitemap.xml --noout
xmllint --schema siteindex.xsd sitemap_index.xml --noout
  1. オンラインバリデータ:
    • https://www.xml-sitemaps.com/validate-xml-sitemap.html
    • https://www.websiteplanet.com/webtools/sitemap-validator/
  2. curl で生バイト確認:
# サーバから取得して BOM の有無を確認
curl -s https://example.com/sitemap.xml | hexdump -C | head -3

# Content-Type が text/xml か application/xml になっているか確認
curl -I https://example.com/sitemap.xml
# Content-Type: application/xml; charset=utf-8  ← 推奨

# サーバが gzip を返している場合
curl -H "Accept-Encoding: gzip" -I https://example.com/sitemap.xml.gz

サーバ側 Content-Type 設定

# Apache (.htaccess または httpd.conf)
AddType application/xml .xml
AddType application/xml .xml.gz
AddEncoding gzip .gz
# Nginx (server ブロック)
location ~* \.xml$ {
    add_header Content-Type "application/xml; charset=utf-8";
}

location ~* \.xml\.gz$ {
    add_header Content-Encoding "gzip";
    add_header Content-Type "application/xml; charset=utf-8";
}

修正後の再送信

  1. 修正したサイトマップをサーバにアップ
  2. キャッシュ削除 (CDN / Cloudflare Cache Purge)
  3. ブラウザで直接アクセスし、表示が正しいか確認
  4. Google Search Console → サイトマップ → 該当 URL の三点メニュー再送信
  5. または既存登録を削除 → 新規追加で再送
  6. 数時間〜数日で「成功」ステータスに変わるか確認

正しいサイトマップ例 (テンプレ)

<?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>
  <url>
    <loc>https://example.com/about</loc>
    <lastmod>2026-05-15</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
</urlset>
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-pages.xml</loc>
    <lastmod>2026-06-10T09:00:00+09:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-articles.xml</loc>
    <lastmod>2026-06-10T09:00:00+09:00</lastmod>
  </sitemap>
</sitemapindex>

FAQ

Q: 何度修正しても同じエラーが消えない
A: CDN や Cloudflare のキャッシュが古い XML を返している可能性。Cache Purge してから再送信。

Q: http://https:// の名前空間どちらが正しい?
A: 正式仕様は http://www.sitemaps.org/schemas/sitemap/0.9 (httpで)。Google は両方受理しますが、互換性のため http 版が安全。

Q: 自動生成プラグインの出力が NG だった
A: プラグイン側のバグ。最新版にアップデートするか、競合プラグインの干渉を疑う (Yoast と All in One が両方有効など)。