泰州网络公司 浏览次数:0 发布时间:2026-04-13
网站生成百度站点地图全攻略
百度站点地图 (Sitemap) 是帮助百度爬虫发现网站页面的重要工具,支持XML 格式和TXT 格式,以下是完整生成指南。
一、百度站点地图格式规范
1. XML 格式 (推荐)
xml
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.wankseo.com/</loc> <!-- 必选,完整URL,长度≤256字节 -->
<lastmod>2026-04-13T14:30:00+08:00</lastmod> <!-- 可选,最后修改时间 -->
<changefreq>daily</changefreq> <!-- 可选,更新频率:always/hourly/daily/weekly/monthly/yearly/never -->
<priority>1.0</priority> <!-- 可选,站内优先级:0.0-1.0,首页建议1.0 -->
</url>
<!-- 更多页面... -->
</urlset>
2. TXT 格式 (简单版)
每行一个 URL,仅包含 loc 字段,示例:
plaintext
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> https://www.wankseo.com/
https://www.wankseo.com/about.html
https://www.wankseo.com/contact.html
3. 关键限制
- 单个文件较多包含50,000 条 URL,大小不超过10MB
- 超过限制需分多个文件,用索引文件 (sitemap_index.xml) 管理
- 必须使用UTF-8 无 BOM 编码保存,否则会报错
二、生成方法 (按技术难度排序)
1. 在线工具生成 (适合新手 / 小型网站)
- 选择工具:XML-Sitemaps、爱站网站地图生成器、ToolsPivot 等
- 输入网站 URL,设置参数 (抓取深度、排除路径等)
- 点击 "生成",等待工具抓取网站页面
- 下载生成的 sitemap.xml 文件
- 上传到网站根目录 (如https://wankwo.com/sitemap.xml)
2. CMS 插件生成 (适合 WordPress / 织梦等系统)
WordPress 示例:
- 安装插件:Baidu Sitemap Generator
- 启用后进入设置→Baidu Sitemap 配置参数
- 点击 "生成站点地图",自动创建 sitemap.xml
- 插件可设置自动更新,无需手动操作
织梦 / Discuz 等:
3. 手动创建 (适合极小型网站 / 特殊需求)
- 新建文本文件,命名为 sitemap.xml
- 按 XML 格式规范编写内容,包含所有重要页面 URL
- 保存为 UTF-8 无 BOM 编码
- 上传到网站根目录
4. 程序自动生成 (适合大型 / 动态网站)
PHP 示例代码:
php
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg>运行
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 0px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"></svg> <?php
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// 连接数据库获取页面列表
$pages = [
['url' => 'https://wankseo.com/', 'lastmod' => '2026-04-13', 'priority' => '1.0'],
['url' => 'https://wankseo.com/article1', 'lastmod' => '2026-04-12', 'priority' => '0.8'],
// 更多页面...
];
foreach($pages as $page) {
echo '<url>';
echo "<loc>{$page['url']}</loc>";
echo "<lastmod>{$page['lastmod']}T00:00:00+08:00</lastmod>";
echo "<priority>{$page['priority']}</priority>";
echo '</url>';
}
echo '</urlset>';
?>
- 上传到网站,访问该 PHP 文件即可生成实时站点地图
4. 命令行工具生成 (适合技术人员)
使用 Screaming Frog SEO Spider、wget 等工具批量抓取 URL,再用脚本转换为站点地图格式
三、提交与优化步骤
1. 准备工作
- 确保网站可正常访问,无死链
- 检查 robots.txt,允许百度爬虫访问 sitemap 文件和所有页面
- 在 robots.txt 中添加:
Sitemap: https://wankseo.com/sitemap.xml
2. 百度搜索资源平台提交
- 登录百度搜索资源平台 (https://ziyuan.baidu.com/)
- 添加网站并验证所有权 (文件验证 / CNAME 验证 / HTML 标签验证)
- 进入 "资源提交"→"数据提交"→"sitemap"
- 输入 sitemap URL (如https://wankseo.com/sitemap.xml),点击提交
- 查看提交状态,处理可能的错误
3. 维护与更新
- 定期更新站点地图 (内容更新频繁的网站建议每天更新)
- 新增重要页面时及时添加到 sitemap
- 定期检查死链,更新 lastmod 字段
- 大型网站建议分目录生成多个 sitemap,提高抓取效率
四、常见问题与解决
表格
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 24px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">
</svg>
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 24px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">
</svg>
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-variant-position: normal; font-stretch: normal; line-height: 24px; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">
</svg>
| 问题 | 解决方法 |
|---|
| 提交后显示 "XML 格式错误" | 检查编码是否为 UTF-8 无 BOM,标签是否正确嵌套,URL 是否完整 |
| 抓取不到所有页面 | 检查 robots.txt 是否禁止爬虫,或使用深度抓取工具 |
| 提交后无效果 | 确保 sitemap 可公开访问,等待百度处理 (通常数小时到 1 天) |
| 文件过大 | 拆分多个 sitemap,使用索引文件管理 |
总结
生成百度站点地图并不复杂,新手推荐使用在线工具或 CMS 插件,快速生成符合规范的 sitemap.xml;技术人员可根据需求选择手动创建或程序生成。关键是确保格式正确、内容完整,并及时提交到百度搜索资源平台,帮助百度更好地发现和收录网站页面,提升 SEO 效果。
需要我根据你的网站类型(WordPress / 织梦 / 自定义开发等)和规模,给出具体生成工具 / 插件推荐及可直接复用的 sitemap.xml 模板吗?