星期二, 十月 16, 2007

google sitemap

今天花了点时间了解了一下 google sitemap_gen,并在项目的文档站点上部署了一下,主要是为了使其更利于搜索以促进项目的推广。

首先从 sourceforge 上下载 sitemap_gen,解开后,拷贝 example_config.xml 为 config.xml,拷贝 example_urllist.txt 为 ulfs_urllist.txt,编辑这两个文件。config.xml 文件我只保留了 URL 和 URLLIST 两种方法,指定 base_url 和 store_into 到站点根目录下的 sitemap.xml.gz 文件,这样 google 可以通过 web 访问到这个 sitemap 文件,urllist 指向到 ulfs_urllist.txt:
http://crablfs.sourceforge.net
http://crablfs.sourceforge.net/index.html lastmod=2007-10-14T22:48:00+01:00 changefreq=monthly priority=1.0
http://crablfs.sourceforge.net/sysadm_zh_CN.html lastmod=2007-09-25T22:17+01:00 changefreq=monthly priority=0.3
http://crablfs.sourceforge.net/tree.html lastmod=2007-07-05T03:32:00+01:00 changefreq=monthly priority=0.5
http://crablfs.sourceforge.net/ru_data_man_zh_CN.html lastmod=2007-10-15T01:14:00+01:00 changefreq=weekly priority=0.6
然后上传 3 个文件:config.xml, ulfs_urllist.txt 和 sitemap_gen.py 到站点根目录下。

接着使用 ssh 登录到站点,运行 sitemap_gen.py 命令:
[chowroc@pr-shellC htdocs]$ python sitemap_gen.py --config=config.xml
Reading configuration file: config.xml
Opened URLLIST file: ulfs_urllist.txt
[WARNING] Discarded URL for not starting with the base_url: http://crablfs.sourceforge.net
Sorting and normalizing collected URLs.
Writing Sitemap file "/home/groups/c/cr/crablfs/htdocs/sitemap.xml.gz" with 4 URLs
Notifying search engines.
Notifying: www.google.com
[WARNING] Cannot contact: www.google.com
Count of file extensions on URLs:
4 .html
Number of errors: 0
Number of warnings: 2
去掉 ulfs_urllist.txt 中的第一行,在运行:
[chowroc@pr-shellC htdocs]$ python sitemap_gen.py --config=config.xml
Reading configuration file: config.xml
Opened URLLIST file: ulfs_urllist.txt
Sorting and normalizing collected URLs.
Writing Sitemap file "/home/groups/c/cr/crablfs/htdocs/sitemap.xml.gz" with 4 URLs
Notifying search engines.
Notifying: www.google.com
[WARNING] Cannot contact: www.google.com
Count of file extensions on URLs:
4 .html
Number of errors: 0
Number of warnings: 1
仍然报告无法 contact www.google.com,那么可以登录到 google 的 Webmaster tools,手工添加 sitemap,在 "Sitemaps" 中提交:
http://crablfs.sourceforge.net/sitemap.xml.gz
等待一段时间之后,可以看到已经正确提交的显示。

关于 google sitemap_gen 的使用文档在:
https://www.google.com/webmasters/tools/docs/en/sitemap-generator.html

没有评论: