0

This is the format of my sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset
    xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="https://www.w3.org/1999/xhtml"
    xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9
        https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
    <loc>https://example.com</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="en-us"
               href="https://example.com" />
    <xhtml:link 
               rel="alternate"
               hreflang="en-gb"
               href="https://example.com/uk/" />
    <xhtml:link 
               rel="alternate"
               hreflang="x-default"
               href="https://example.com" />
</url>
</urlset>

However, search console keeps giving me the error that it has an incorrect namespace on Line 10.

I have also tried the solution available here: XSD For Sitemap with HREFLANG

But I get the same error on that. What am I doing wrong?

4

1 回答 1

1

Turns out, Google does not like xmlns:xhtml="https://www.w3.org/1999/xhtml" to be HTTPS.

Turning it into non-HTTPs seems to have fixed the issue, i.e.

<urlset
    xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9
        https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>

It does get rid of the default XML styling in the browser view but the sitemap validates. I suppose the styling could be customised with an XSL, if necessary.

于 2019-06-17T10:10:00.930 回答