使用自定义属性创建有效的站点地图

时间:2021-01-07 17:15:16

I'm working on a website. My website has a sitemap.xml file. That file can be seen here.

我在网站上工作。我的网站有一个sitemap.xml文件。那个文件可以在这里看到。

If you scroll down, you will see a url entry that includes some custom tags. Those tags are prefixed with blog: The definition for the blog namespace can be seen here.

如果向下滚动,您将看到包含一些自定义标记的网址条目。这些标签以博客为前缀:博客命名空间的定义可以在这里看到。

I've submitted my sitemap to the Google Webmaster Tools. However, I receive warnings around the entries associated with the blog namespace. Those warnings appear as shown here:

我已将我的站点地图提交给Google网站管理员工具。但是,我收到与博客命名空间相关的条目的警告。这些警告如下所示:

Warnings 

Invalid XML tag 

This tag was not recognized. Please fix it and resubmit. 

Parent tag: url
Tag: title 

Parent tag: url
Tag: description 

Parent tag: url
Tag: author 

I would really like to include some custom elements in my sitemap file. At the same time, I want to ensure that my sitemap.xml does not generate any warnings. My question is, is this possible? If so, what am I doing wrong? Thank you!

我真的想在我的站点地图文件中包含一些自定义元素。同时,我想确保我的sitemap.xml不会生成任何警告。我的问题是,这可能吗?如果是这样,我做错了什么?谢谢!

3 个解决方案

#1


0  

I am using a custom namespace for attributes in my sitemap: http://pics.jonathancross.com/sitemap.xml

我在我的站点地图中为属性使用自定义命名空间:http://pics.jonathancross.com/sitemap.xml

They seem to work fine.

他们似乎工作得很好。

The following attributes are part of the jcd namespace:

以下属性是jcd命名空间的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset
    xmlns:jcd="http://pics.jonathancross.com"
    jcd:date="2015-09-16"
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url jcd:imgs="0" jcd:dsize="1.3G">
    <loc>http://pics.jonathancross.com/</loc>
    <lastmod>2015-09-16</lastmod>
    <priority>1.0</priority>
  </url>
  ...

I also use a custom desc element like this:

我也使用这样的自定义desc元素:

<jcd:desc>Description of page here</jcd:desc>

The element causes errors in Google Webmaster Tools, however Webmaster Tools still seems to parse the sitemap data it understands.

该元素会导致Google网站站长工具中的错误,但网站管理员工具似乎仍然会解析其理解的站点地图数据。

Motivation:

Adding custom data to my sitemap means it can be used as a central database for my site. I also use xslt to render the same data into a structured table of links for humans to browse the site.

将自定义数据添加到我的站点地图意味着它可以用作我的站点的*数据库。我还使用xslt将相同的数据呈现到一个结构化的链接表中,供人们浏览网站。

#2


0  

Shouldn't the target namespace of the "blog" schema be the same as the one you assign in it in your sitemap?

“博客”架构的目标命名空间不应该与您在站点地图中分配的目标命名空间相同吗?

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
** xmlns:blog="http://www.ecofic.com" **     
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9     
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd     
http://www.ecofic.com/resources/root/blog/1.0 
http://www.ecofic.com/resources/root/blog.xml">

#3


0  

Defining the namespace attribute as follows?

如下定义命名空间属性?

<html xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:blog="http://www.google.com/2005/gml/b">

#1


0  

I am using a custom namespace for attributes in my sitemap: http://pics.jonathancross.com/sitemap.xml

我在我的站点地图中为属性使用自定义命名空间:http://pics.jonathancross.com/sitemap.xml

They seem to work fine.

他们似乎工作得很好。

The following attributes are part of the jcd namespace:

以下属性是jcd命名空间的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset
    xmlns:jcd="http://pics.jonathancross.com"
    jcd:date="2015-09-16"
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url jcd:imgs="0" jcd:dsize="1.3G">
    <loc>http://pics.jonathancross.com/</loc>
    <lastmod>2015-09-16</lastmod>
    <priority>1.0</priority>
  </url>
  ...

I also use a custom desc element like this:

我也使用这样的自定义desc元素:

<jcd:desc>Description of page here</jcd:desc>

The element causes errors in Google Webmaster Tools, however Webmaster Tools still seems to parse the sitemap data it understands.

该元素会导致Google网站站长工具中的错误,但网站管理员工具似乎仍然会解析其理解的站点地图数据。

Motivation:

Adding custom data to my sitemap means it can be used as a central database for my site. I also use xslt to render the same data into a structured table of links for humans to browse the site.

将自定义数据添加到我的站点地图意味着它可以用作我的站点的*数据库。我还使用xslt将相同的数据呈现到一个结构化的链接表中,供人们浏览网站。

#2


0  

Shouldn't the target namespace of the "blog" schema be the same as the one you assign in it in your sitemap?

“博客”架构的目标命名空间不应该与您在站点地图中分配的目标命名空间相同吗?

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
** xmlns:blog="http://www.ecofic.com" **     
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9     
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd     
http://www.ecofic.com/resources/root/blog/1.0 
http://www.ecofic.com/resources/root/blog.xml">

#3


0  

Defining the namespace attribute as follows?

如下定义命名空间属性?

<html xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:blog="http://www.google.com/2005/gml/b">