+
95
-

如何生成百度喜欢的站点sitemap.xml?

听说百度都是根据sitemap.xml来进行站点索引,如果没有好的sitemap,可能百度不会搭理你的?是这样吗

网友回复

+
15
-

百度一般都是通过站的sitemap.xml来进行页面爬取和索引,所以你必须在网站的根目录下生成一个sitemap.xml文件,让百度知道你的站点更新的啥,sitemap.xml的地址可以放到 robots.txt 文件中。

根目录 robots.txt如下,这里定义了user-agent,表示容许哪些爬虫来爬取,*表示所有,百度叫Baiduspider,谷歌叫Googlebot,Disallow表示哪些页面和目录不容许爬取。注意:sitemap 谷歌为xml格式,百度为html格式

User-agent: *
Disallow: 
Disallow: /admin/
Sitemap: http://domain.com/sitemap.xml

那么sitemap怎么写呢

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">
    <url>
        <loc>https://www.domian.com/</loc>
        <mobile:mobile ...

点击查看剩余70%

我知道答案,我要回答