如何为主站点和博客(在子域中)安排站点地图

How to arrange sitemaps for main site and for blog (in subdomain)

我有两个网站:主站点和一个博客,其中的帖子与主站点的内容密切相关。该博客位于子域 "blog."

wwww.example.com
blog.example.com

主站点上的内容不会经常更改,但博客上的内容每周都会更改。该博客只是一个 Wordpress 站点,能够生成自己的站点地图。

我正在苦苦思索如何安排站点地图。

我可以想到两个选项,但我不确定哪个是最好的。也许还有我不知道的第三种选择。

选项 1

<sitemap>
  <loc>http://www.example.com</loc>
  <lastmod>2006-10-01T18:23:17+00:00</lastmod>

  <loc>http://www.example.com/about</loc>
  <lastmod>2006-10-01T18:23:17+00:00</lastmod>

  <loc>http://blog.example.com</loc>
  <lastmod>2006-10-01T18:23:17+00:00</lastmod>
</sitemap>

在这种情况下,我想搜索引擎会抓取到博客子域,但我不确定他们如何在那里找到站点地图。我只相信搜索引擎会根据我直接通过网站管理员工具上传的网站地图找到它们。

`

选项 2

主站点地图可以列出多个站点地图。

 <sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">
   <sitemap>
    <loc>http://www.example.com/sitemaps/sitemap.xml</loc>
    <lastmod>2006-10-01T18:23:17+00:00</lastmod>
   </sitemap>
   <sitemap>
     <loc>http://blog.example.com/sitemap.xml</loc>
     <lastmod>2006-10-01</lastmod>
  </sitemap>

 </sitemapindex>

此处的最佳做法是什么?

你的两个选项都不被允许。

您需要为每个主机(例如,子域)创建一个单独的站点地图文件。而且你不能从同一个 Sitemap 索引文件中 link 到这些 Sitemap 文件,也就是说,每个主机也需要它自己的 Sitemap 索引文件(如果你想使用一个)。

关于搜索引擎如何找到站点地图(索引)文件,请参阅

来源

来自Sitemaps protocol specification about file location

Note that this means that all URLs listed in the Sitemap must use the same protocol (http, in this example) and reside on the same host as the Sitemap. For instance, if the Sitemap is located at http://www.example.com/sitemap.xml, it can't include URLs from http://subdomain.example.com.

来自Sitemaps protocol specification about index files

A Sitemap index file can only specify Sitemaps that are found on the same site as the Sitemap index file. For example, http://www.yoursite.com/sitemap_index.xml can include Sitemaps on http://www.yoursite.com but not on http://www.example.com or http://yourhost.yoursite.com.