Should an HTTPS Sitemap Use HTTP in xmlns?
Use the standard namespace in your XML sitemap. Compare four declarations and check the page URL in a loc element.
Like it ? share it
Use http://www.sitemaps.org/schemas/sitemap/0.9 as the namespace in your XML sitemap. Keep the HTTPS address of your page in <loc>. An HTTPS site can use both values in the same file. Sitemaps protocol
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/shop/</loc>
</url>
</urlset>Here, xmlns gives the default namespace for the XML elements. The text inside <loc> gives the address of the shop page. A change to the namespace does not change that address.
What one extra character changes
XML compares namespace names character by character. The extra s in https changes the name. A slash after 0.9 also changes the name. W3C rules for namespace names
In a local test, a Python XML parser read four versions of the example. Each version contained the same shop URL. We searched for a <loc> element under <url> in the standard namespace.
| Namespace declaration | Could the parser read the XML? | Number of matches |
|---|---|---|
| The declaration in the example | Yes | 1 |
The same name with https:// |
Yes | 0 |
| The same name with a final slash | Yes | 0 |
| No declaration | Yes | 0 |
All four files contained a <loc> element. Only the first file put that element in the namespace from the protocol. The test checked XML names on one computer. Google reports its result for a submitted file in Search Console. Google Sitemaps report
Check an “Incorrect namespace” error
- Open the XML source of the sitemap from the report.
- Find the opening
<urlset>tag for the list of pages. - Compare its default namespace with the value in the example.
- If the values differ, correct the namespace in the sitemap generator.
- Generate the sitemap again.
- Check the namespace in the new file.
- Compare one
<loc>value with the intended page URL.
For a sitemap index, find the opening <sitemapindex> tag in step 2. It uses the same namespace. Google's namespace examples
For a separate check of a public sitemap, enter its URL in the Enfect Sitemap Error Checker. If the server sends an HTML page, follow the procedure to inspect the sitemap response.