タイトル: エラー一覧 (sitemap.xml)
SEOタイトル: sitemap.xml エラー総合 — Incorrect namespace / unable to parse XML / URL not allowed
| この記事の要点 |
|
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 namespace | xmlns 誤り | 正しい URI に修正 |
| unable to parse XML | 構文エラー / BOM / 文字化け | UTF-8 (BOM無)、タグ閉じ |
| Empty sitemap | URL を 1 つ以上 | |
| URL not allowed | ドメイン / プロトコル不一致 | sitemap と同 host に |
| Tag mismatch | 未閉じ / 重複 タグ | XML Linter で検出 |
| Sitemap index too large | 50,000 URL / 50MB 超 | index 分割 |
| Invalid XML: too many tags | タグ重複 | 1 url 内に loc は 1 個 |
| Invalid date | lastmod 形式エラー | ISO 8601 (YYYY-MM-DD) |
| Compression error | gzip ヘッダ無し | 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-8 | head -c 3 sitemap.xml | xxd → ef bb bf |
| Shift_JIS / EUC-JP | file 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 での確認
- Search Console → 該当プロパティ → サイトマップ
- 新規 sitemap を追加 (例:
sitemap.xml) - ステータスを確認: 「成功」 / 「取得できませんでした」 / 「エラー」
- エラー内容を展開して該当 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: priority や changefreq は意味ある?
A: Google はほぼ無視すると公式表明。lastmod は読まれる。priority/changefreq は省略してよい。