在 百度、 google 站长工具中使用 sitemap 总结

背景

使用jekyll 生成的blog sitemap 提交后,一直提示 xml解析失败,最后发现是sitemap种类使用错误导致的,把索引文件当成了地图文件使用。

sitemap 种类

百度 sitemap分两类:站点地图索引文件站点地图,站点地图就是站点中每个页面的链接,而站点地图索引文件即为指向站点地图的链接,发现问题原因后,问题自然很容易解决。 同时发现,利用__站点地图索引文件__ 很容易解决另外一个一直想解决的问题。

站点地图索引文件的一种 使用姿势

我写blog的域名是blog.soul11201.com, 原先一直使用hexo在写文章,现在想换用jekyll, 但是还想使用这个域名,但是原先写了很多文章 也不想做迁移,故用了一个新的域名 hexo.soul11201.com 指向原来的站点, 这样就需要解决同一域名下多站点的索引问题

但如果如果使用站点地图索引文件, 把两个站点的站点地图放到站点地图索引文件,很容易解决了多站点的索引问题。我使用的具体的解决方案就是:

  • 首先生成站点索引文件和站点地图文件(下面两个文件内容即是)
  • 然后将www.soul11201.com cname到 blog.soul11201.com
  • 直接提交站点索引文件http://www.soul11201.com/mulsitemap.xml到百度

jekyll 站点索引文件 /mulsitemap.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="utf-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemapindex>
<sitemap>
<loc>http://blog.soul11201.com/sitemap.xml</loc>
<lastmod>{{ site.time | date: "%Y-%m-%d" }}</lastmod>
</sitemap>

<sitemap>
<loc>http://hexo.soul11201.com/atom.xml</loc>
<lastmod>2016-05-07</lastmod>
</sitemap>

</sitemapindex>

jekyll blog 站点地图生成文件 /sitmap.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="utf-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemapindex>
<sitemap>
<loc>http://blog.soul11201.com/sitemap.xml</loc>
<lastmod>{{ site.time | date: "%Y-%m-%d" }}</lastmod>
</sitemap>

<sitemap>
<loc>http://hexo.soul11201.com/atom.xml</loc>
<lastmod>2016-05-07</lastmod>
</sitemap>

</sitemapindex>

扩展阅读


在 百度、 google 站长工具中使用 sitemap 总结
http://blog.soul11201.com/2016/08/09/sitemap/
作者
soul11201
发布于
2016年8月9日
许可协议