谦卑的程序员






         静水流深

December 11, 2008

Wordpress mu的Google Sitemap插件

Filed under: Wordpress (mu) — Eric Tou @ 4:29 pm
Tags: , ,

  为站点生成站点地图能够方便用户浏览,而生成XML格式的Sitemap文件则方便Google等搜索引擎了解网站的结构和更新情况,更好更快地收录网站的内容,为网站带来浏览量。

  一般Sitemap文件都是由发布平台的插件自动生成,比如Wordpress平台上有Google (XML) Sitemaps Generators。Wordpress mu是Wordpress的多用户版本,因为涉及到多用户独立配置的需要,两者的插件并不完全能通用。为了符合要求,有时还需要修改插件的源代码。当然,修改源代码一般是最后的解决方案。
  在WPMU DEV列出了一些专门适用于Wordpress mu的插件,目前总共有150多个,每页10个,没有分类也没有站内搜索,翻翻找找找到了Standard XML Sitemap Plugin
  这个插件会为Wordpress mu中的每个站点分别生成sitemap文件。比较特别的是它并不生成静态的XML文件,而是在每次收到请求的时候自动生成。

  下载安装包后解压,得到两个php文件。将’xml-sitemap.php’上传至’/wp-content/mu-plugins/’,将’feed-sitemap.php’上传至’/wp-includes/’。因为这是全局的插件,上传完成后无需启用就已经在运行了。
  如上所述,该插件不会在站点的根目录生成sitemap.xml,要确认效果只需要访问http://your-wordpressmu-site/blog/sitemap.xml即可。

  接下来就是向搜索引擎提交sitemap,比如Google Webmaster Tools,一般按照界面提示将sitemap的URL地址填写并提交即可。

问题:
  
作者的站点,有几位用户留言提到了两个主要的问题:一个是日期格式如’2008-10-07T19:35:50 +0000’当中的空格会导致Google Webmaster Tools提示Invalid Date的警告信息(这个问题很奇怪的在我的两个站点中只有一个提示)。一个是sitemap.xml列出的post数量太少。
  对此一位名叫sirjoe的用户给出了他的修改。文章是用意大利语写的,但代码就是最好的交流语言。

  编辑feed-sitemap.php
  源代码第19行和39行,将‘Y-m-d\TH:i:s +0000′修改为‘Y-m-d\TH:i:s+00:00’,去除+前面的空格,在00前添加: 。解决Invalid Date的问题。
  源代码第26行,将‘SELECT … DESC LIMIT 100’中的100改为你想要的数字。

  最终还是修改了源代码,不过开源软件就是这样。修改一个Wordpress mu的插件的问题还是比修改一个Wordpress的插件让它来适应mu要好一些。

June 24, 2008

提交网站至Google搜索引擎

Filed under: 1.2 Web开发 — Eric Tou @ 6:31 pm
Tags: , , ,

    After you published your website, Submit your website to search engine is a good idea to help your visitor find you. Firstly, of course my favorite Google.

    Through this url, you can submit the URL of your website to Google search engine, and then the GoogleBot will index the entire website.
    But that’s not enough, Through Webmaster Tools, you can submit a XML Sitemap of your website and use tools to increase your site’s visibility on Google.
    Why? Read <What is a Sitemap file and why should I have one>

    How? Manually create a sitemap file for a dynamic cms system like drupal is impossible, a mature cms always has its solution:
XML Sitemap module (replaced the old Google Sitemap from Drupal 5), can automatically create a site map which support Google, Yahoo, Windows Live, Ask engines.

    After installed and enabled this module, fill the location of the Sitemap file in Webmaster Tools like http://{hostname}/sitemap.xml , Done.

WPMU Theme pack by WPMU-DEV.