I’m trying to extend a sitemap.xml to include some custom data so I don’t have to store it in a separate database but just in-file. From what I found online, some people say xml namespaces should allow custom fields to work with sitemaps ( 1, 2 ), others say search engines might reject it ( 1, 2 ). Which one is true? Is there an objective truth, at least per engine?
And as for how, from what I understand, I need to define my namespace schema in an xsd file.
This is what I’ve come up with, but I don’t know how to even test it. Could someone tell me if this is correct?
sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:saleor="http://example.org/xml-schemas/saleor-ref.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.org/cat/product</loc>
<lastmod>2020-02-17</lastmod>
<saleor:ref>
<saleor:id>coolsaleoridofaproduct</saleor:id>
<saleor:category>coolidoftheparentcategory</saleor:category>
</saleor:ref>
</url>
<url>
<loc>http://example.org/cat</loc>
<lastmod>2021-02-17</lastmod>
<saleor:ref>
<saleor:id>coolsaleoridofaproduct</saleor:id>
</saleor:ref>
</url>
</urlset>
saleor-ref.xsd
– I assume has to be hosted at targetNamespaces url?
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/xml-schemas/saleor-ref.xsd">
<xs:element name="ref">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="category-id" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Thanks <3