原稿:xhhnet 技術支持:wm_chief,hicode 整理:24mp3
GOOGLE SITEMAP 的制作xhhnet已給出詳細方法(http://bbs.phome.net/ShowThread/?threadid=28212&forumid=13),不過我發現其中并不包括重要的欄目地址,而且有個小地方未做說明,所以有不少人照做后發現提交后GOOGLE頁面顯示SITEMAP出錯。經過詢問WC和hicode,總結方法如下,思路還是原來的,但調用的標簽不一樣。生成的sitemap更合理。并且已全部提交成功。
本方法利用欄目分別創建不同的sitemap,達到SITEMAP分頁的效果,制作出來的SITEMAP完全符合https://www.google.com/webmasters/tools/docs/zh_CN/protocol.html的要求.
新增: 欄目地址 SITEMAP錯誤日期無效原因
一、系統參數設置 -> 信息設置
模板是否支持程序代碼: 是 (一定要先做好這一步,才進行下一步的工作,否則提交后出錯。)
二、打開后臺模板管理 -> 管理標簽模板 -> 增加標簽模板:
1、自定義google地圖標簽
注意:時間顯示格式選擇:Y-m-d (如果是默認的Y-m-d H:i:s,則提交后會顯示Sitemap 錯誤和警告)
頁面模板內容: <url><loc>http://www.yoursite.com[!--the.classurl--]</loc></url> [!--empirenews.listtemp--]<!--list.var1-->[!--empirenews.listtemp--]
列表內容模板: <url><loc>http://www.yoursite.com[!--titleurl--]</loc> <lastmod>[!--newstime--]</lastmod> </url>
2、自定義google地圖索引標簽
注意:時間顯示格式選擇:Y-m-d (如果是默認的Y-m-d H:i:s,則提交后會顯示Sitemap 錯誤和警告)
頁面模板內容: [!--empirenews.listtemp--]<!--list.var1-->[!--empirenews.listtemp--]
列表內容模板: [!--newstime--]
三,開始增加地圖
建立網站地圖涉及到你的網站架構問題,基本原理是有多少個非終極欄目就可以添加多少個地圖,如sitemap1,sitemap2.....這樣的地圖包括了終極欄目的地址和具體文章地址,不過并不包括非終極欄目本身的地址,可以先用一個sitemap999包括這些非終極欄目的地址,然后再一個個添加非終極欄目的sitemap。
模板管理->管理自定義頁面 -> 增加自定義頁面:
(以下先用一個sitemap999包括這些非終極欄目的地址) 1、頁面名稱:網站大類地圖
文件名: ../../sitemap999.xml
頁面內容: <?='<?xml version="1.0" encoding="UTF-8"?>'?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url><loc>http://www.yoursite.com</loc> </url> [listsonclass]'0',0,0,0,3,地圖標簽ID,0,0[/listsonclass] </urlset>
(以下添加非終極欄目的sitemap) 2、頁面名稱:網站地圖1
文件名: ../../sitemap1.xml
頁面內容: <?='<?xml version="1.0" encoding="UTF-8"?>'?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url><loc>http://www.yoursite.com</loc> </url> [listsonclass]欄目ID,3000,0,0,0,地圖標簽ID,0,0[/listsonclass] </urlset>
3、頁面名稱:網站地圖2
文件名: ../../sitemap2.xml
頁面內容: <?='<?xml version="1.0" encoding="UTF-8"?>'?> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url><loc>http://www.yoursite.com</loc> </url> [listsonclass]欄目ID,3000,0,0,0,地圖標簽ID,0,0[/listsonclass] </urlset>
......
網站地圖3網站地圖4網站地圖5網站地圖6....除文件名外和欄目ID改變外其他同樣.
4.制作地圖索引頁
頁面名稱:網站地圖索引頁
文件名: ../../sitemap_index.xml
頁面內容: <?='<?xml version="1.0" encoding="UTF-8"?>'?> <sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84"> <sitemap> <loc>http://www.yoursite.com/sitemap999.xml</loc> <lastmod>[ecmsinfo]'0',1,0,0,3,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap1.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap2.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap3.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap4.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap5.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> <sitemap> <loc>http://www.yoursite.com/sitemap6.xml</loc> <lastmod>[ecmsinfo]欄目ID,1,0,0,0,地圖索引標簽ID,0[/ecmsinfo]</lastmod> </sitemap> </sitemapindex>
四、后臺 -> 數據更新 刷新所有自定義頁面。
五、到GOOGLE管理員頁面登錄提交sitemap_index.xml及所有sitemap.
說明:sitemap999.xml是網站大類欄目地址的地圖(不包括具體文章地址),其他sitemap1,sitemap2.....是各個非終極欄目的地圖(包括下面終極欄目的地址和具體文章地址),sitemap_index是所有地圖索引。這樣就基本上一網打盡了帝國系統的所有網址了。
還有sitemap文件不能過大,如果再加上服務器線路不好的情況下,也容易造成GOOGLE收錄出錯,這時請適當減小網站地圖中[listsonclass]欄目ID,3000,...[/listsonclass]中的“3000”數目。這個參數并不是控制sitemap文件的收錄數量,而是控制每個終極欄目加入的文章數量。
個人經驗,一個單個的sitemap控制在3MB左右,GOOGLE是可以接受的。
提交成功后,以后網站有更新時,在帝國后臺刷新一下相應的自定義sitemap頁面即可。
|