熬了半个通宵,写出了自己的Google SiteMap文件,在这里给出详细编写教程,愿对大家有所帮助。
Google SiteMap的作用及协议格式详解
Google SiteMap PRotocol是Google自己推出的一种站点地图协议,此协议文件基于早期的robots.txt文件协议,并有所升级。在Google官方指南中指出加入了Google SiteMap文件的网站将更有利于Google网页爬行机器人的爬行索引,这样将提高索引网站内容的效率和准确度。文件协议应用了简单的xml格式,一共用到6个标签,其中关键标签包括链接地址、更新时间、更新频率和索引优先权。
Google SiteMap文件生成后格式如下:
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <loc>http://www.knowsky.com</loc> <lastmod>2005-06-03T04:20-08:00</lastmod> <changefreq>always</changefreq> <priority>1.0</priority> </url> <url> <loc>http://www.knowsky.com/300687.html</loc> <lastmod>2005-06-02T20:20:36Z</lastmod> <changefreq>daily</changefreq> <priority>0.8</priority> </url> </urlset>XML标签
changefreq:页面内容更新频率。
lastmod:页面最后修改时间
loc:页面永久链接地址
priority:相对于其他页面的优先权
url:相对于前4个标签的父标签
urlset:相对于前5个标签的父标签
我将一句一句分解讲解这个xml文件的每一个标签:
字符 转义后的字符 HTML字符 字符编码
and(和) & & &
单引号 ' ' '
双引号 " " "
大于号 > > >
小于号 < < <
年:YYYY(2005)
年和月:YYYY-MM(2005-06)
年月日:YYYY-MM-DD(2005-06-04)
年月日小时分钟:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37+08:00)
年月日小时分钟秒:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37:30+08:00)
还有和,这两个就是来关闭xml标签的,这和HTML中的和是一个道理
Another thing to note is that this xml file must be in utf-8 encoding format. Whether you generate it manually or through code, it is recommended to check whether the xml file is utf-8 encoded. The simplest way is Open the xml with notepad and then select the encoding (or converter) to UTF-8 when saving.
Log in to Google to submit your SiteMap file and let Google start crawling. Open the
https://www.google.com/webmasters/sitemaps/ link. If you have not registered or logged in to Google, Just log in to Google with your own account. After logging in, go to the Your Sitemaps status page. You can click Add a Sitemap + to jump to the submission page to submit the Sitemap file. It is recommended that the file be placed in the root directory of your site. After submitting your Sitemap URL to Google, you can see that it already exists in the list, but it has not taken effect yet. It will take a few hours for the Status column to change to OK to officially take effect. If it is not OK, you can check the status indicator given by Google. Explain the reason.
The above is a step-by-step guide to making Google Sitemap (detailed production tutorial and protocol explanation). For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!