免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
移動SEO分享:php自動提交復(fù)合型Sitemap到百度搜索 | 張戈博客

導(dǎo)讀:本文分享的是移動sitemap協(xié)議說明及生成復(fù)合型sitemap的方法。所謂復(fù)合型就是指一個sitemap.xml既包含了pc頁,也包含了mobile頁!一旦提交,雙管齊下,同時搞定了結(jié)構(gòu)化數(shù)據(jù)和移動開放適配!而且此方法適用于任何wordpress建站的網(wǎng)站,包括響應(yīng)式亦可提交帶響應(yīng)式標識的sitemap!所以,網(wǎng)站是響應(yīng)式的童鞋也就別在那“得瑟”你的響應(yīng)式多么多么的高大上了!當(dāng)然,如果你不在乎SEO那也可以不用浪費時間了。


 

不久前,張戈博客曾分享了《移動搜索SEO分享:PHP自動生成百度開放適配及360移動適配專用的Sitemap文件》,不管有沒有人用,反正我用的很愜意,此文也被免費資源部落(freehao123.com)重新整理轉(zhuǎn)載,反響還不錯!

就在前天,驚喜的收到了期盼已久的百度sitemap邀請通知:

雖說,這功能在內(nèi)測的時候隨便用,但是很多新站都沒趕上那一波,暫時都處于邀請狀態(tài):

我在收到邀請通知后,迫不及待地提交了一直在冷板凳坐著的sitemap.xml!

然而不經(jīng)意間,我在這個頁面發(fā)現(xiàn)了新大陸:

趕緊點開看了看:http://zhanzhang.baidu.com/wiki/93#03

三、什么是移動Sitemap協(xié)議,如何提交Sitemap到移動搜索?

百度推出了移動Sitemap協(xié)議,用于將網(wǎng)址提交給移動搜索收錄。百度移動Sitemap協(xié)議是在標準Sitemap協(xié)議基礎(chǔ)上制定的,增加了<mobile:mobile/>標簽,它有三種取值:

  • <mobile:mobile/> :移動網(wǎng)頁

  • <mobile:mobile type="mobile"/> :移動網(wǎng)頁      

  • <mobile:mobile type="autoadapt"/>:自適配網(wǎng)頁,適用于同一網(wǎng)址頁面,會隨設(shè)備不同改變展現(xiàn)的情況。        

  • 無該標簽表示PC的網(wǎng)頁

下方樣例相當(dāng)于向百度移動搜索提交了一個移動網(wǎng)頁:http://m.example.com/index.html,向PC搜索提交了一個傳統(tǒng)網(wǎng)頁:http://www.example.com/index.html,同時向移動搜索和PC搜索提交了一個自適配網(wǎng)頁http://www.example.com/autoadapt.html:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  3. xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">
  4. <url>
  5. <loc>http://m.example.com/index.html</loc>
  6. <mobile:mobile type="mobile"/>
  7. <lastmod>2009-12-14</lastmod>
  8. <changefreq>daily</changefreq>
  9. <priority>0.8</priority>
  10. </url>
  11. <url>
  12. <loc>http://www.example.com/index.html</loc>
  13. <lastmod>2009-12-14</lastmod>
  14. <changefreq>daily</changefreq>
  15. <priority>0.8</priority>
  16. </url>
  17. <url>
  18. <loc>http://www.example.com/autoadapt.html</loc>
  19. <mobile:mobile type="autoadapt"/>
  20. <lastmod>2009-12-14</lastmod>
  21. <changefreq>daily</changefreq>
  22. <priority>0.8</priority>
  23. </url>
  24. </urlset>

 

仔細看了下xml代碼及百度移動sitemap協(xié)議說明,發(fā)現(xiàn)原來sitemap可以同時提交pc頁和mobile頁,如果是自適應(yīng)網(wǎng)站還可以使用自適應(yīng)標識:<mobile:mobile type="autoadapt"/>,具體請細看上方引用說明。

再對比了下我上次寫的那個開放適配的php代碼,10分鐘不到就搞定了這個php!

下面分享php源代碼:

  1. <?php
  2. require('./wp-blog-header.php');
  3. header("Content-type: text/xml");
  4. header('HTTP/1.1 200 OK');
  5. $posts_to_show = 1000; // 獲取文章數(shù)量
  6. echo '<?xml version="1.0" encoding="UTF-8"?>';
  7. echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
  8. echo 'xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">'
  9. ?>
  10. <--PC頁面地址,實際使用請務(wù)必刪除此行注釋-->
  11.   <url>
  12.       <loc>http://zhangge.net/</loc>
  13.       <lastmod><?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate('Y-m-d\TH:i:s+00:00', strtotime($ltime)); echo $ltime; ?></lastmod>
  14.       <changefreq>daily</changefreq>
  15.       <priority>1.0</priority>
  16.   </url>
  17. <--mobile頁面地址,實際使用請務(wù)必刪除此行注釋-->
  18.   <url>
  19.       <loc>http://m.zhangge.net/</loc>
  20.       <mobile:mobile type="mobile"/>
  21.       <lastmod><?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate('Y-m-d\TH:i:s+00:00', strtotime($ltime)); echo $ltime; ?></lastmod>
  22.       <changefreq>daily</changefreq>
  23.       <priority>1.0</priority>
  24.   </url>
  25. <--自適應(yīng)頁面地址,實際使用請務(wù)必刪除此行注釋-->
  26.   <url>
  27.       <loc>http://m.zhangge.net/</loc>
  28.      <mobile:mobile type="autoadapt"/>
  29.       <lastmod><?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate('Y-m-d\TH:i:s+00:00', strtotime($ltime)); echo $ltime; ?></lastmod>
  30.       <changefreq>daily</changefreq>
  31.       <priority>1.0</priority>
  32.   </url>
  33. <?php
  34. header("Content-type: text/xml");
  35. $myposts = get_posts( "numberposts=" . $posts_to_show );
  36. foreach( $myposts as $post ) { ?>
  37. <--PC頁面地址,實際使用請務(wù)必刪除此行注釋-->
  38.   <url>
  39.       <loc><?php the_permalink(); ?></loc>
  40.       <lastmod><?php the_time('c') ?></lastmod>
  41.       <changefreq>monthly</changefreq>
  42.       <priority>0.6</priority>
  43.     </url>
  44. <--mobile頁面地址,實際使用請務(wù)必刪除此行注釋-->
  45.   <url>
  46.       <loc><?php echo str_replace("zhangge.net","m.zhangge.net",the_sitemaplink()); ?></loc>
  47.       <mobile:mobile type="mobile"/>
  48.       <lastmod><?php the_time('c') ?></lastmod>
  49.       <changefreq>monthly</changefreq>
  50.       <priority>0.6</priority>
  51.     </url>
  52. <--自適應(yīng)頁面地址,實際使用請務(wù)必刪除此行注釋-->
  53.   <url>
  54.       <loc><?php the_permalink(); ?></loc>
  55.       <mobile:mobile type="autoadapt"/>
  56.       <lastmod><?php the_time('c') ?></lastmod>
  57.       <changefreq>monthly</changefreq>
  58.       <priority>0.6</priority>
  59.     </url>
  60. <?php } // end foreach ?>
  61. </urlset>

 

使用說明:

①、必須收到了百度sitemap提交權(quán)限的邀請后才能使用,當(dāng)然你也可以放到根目錄,弄個鏈接等蜘蛛自己爬;

②、如果是自適應(yīng)的網(wǎng)站,僅需要保留 <--自適應(yīng)頁面地址,實際使用請務(wù)必刪除此注釋-->的<url>部分即可;

③、如果是自適應(yīng)網(wǎng)站,請刪除 <--自適應(yīng)頁面地址,實際使用請務(wù)必刪除此注釋-->的<url>部分;

Ps:所謂<url>部分,就是如代碼中48~55行之間的類似單元內(nèi)容,還不理解請多吃點“靈泛得樂”膠囊!

④、此代碼只提交了文章頁面,如果介意的話,可以僅保留mobile頁面,去提交移動sitemap即可,pc頁面可另行使用插件生成更完整的sitemap.xml。

目前張戈博客就是用的這個方法,同時向百度提交2種sitemap.xml:

⑤、由于篇幅有限,就不復(fù)述其他相同的使用說明了!實際使用,請務(wù)必參考《移動搜索SEO分享:PHP自動生成百度開放適配及360移動適配專用的Sitemap文件》中的使用方法,比如偽靜態(tài)、添加function函數(shù)等。

寫在最后:個人覺得提交這個sitemap會比做開放適配的效果好得多!當(dāng)然,前提是你的域名已開通了百度站長平臺的sitemap提交功能才可以用。已有權(quán)限的童鞋趕緊試試看吧!

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
sitemap的詳細用法和需求解析
網(wǎng)站地圖sitemap.xml解析
怎樣創(chuàng)建sitemap文件
dedecms制作網(wǎng)站地圖 wordpress經(jīng)典google sitemap
WordPress免插件生成完整站點地圖(sitemap.xml)的php代碼 | 張戈博客
多個sitemap文件該如何處理 如何向搜索引擎提交多個sitemap文件?
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服