使用 TXT 纯文本的站点地图需要注意哪些事项?

站点地图(sitemap)包括 xml、txt、html 等格式。本文主要介绍使用纯文本站点地图需要注意的事项。

文本(txt)格式站点地图

如果你的站点地图只包含网页网址,那么你可以仅向搜索引擎提供简单的文本文件[1](每行只包含一个网址)。例如:

https://video.fuyeor.com/watch/FXziOoU7PSM8Dau
https://video.fuyeor.com/watch/757cSn4KS3JdGC8
https://video.fuyeor.com/watch/xDzz4CCqDwGqyAl
https://video.fuyeor.com/watch/croatian-rhapsody
https://video.fuyeor.com/watch/iYUJxYaijYZfMLZ
.....

文本格式站点地图注意事项

1、使用 UTF-8 编码对 txt 文本文档进行编码。

2、请勿在站点地图文件中添加除网址以外的任何其他内容,例如注释等等。如下面的示例是错误的:

# video.fuyeor.com 的文本站点地图
https://video.fuyeor.com/watch/扭曲变形的多边形_BUcGGofQj5TgfJn.html

3、可以随意对该文本文件进行命名,但前提是要确保它的扩展名为 .txt(例如,sitemap.txt)。

4、需要将 url 中除了参数外的非拉丁字符(a-z)进行 urlencode(转码)。

例如下面带有中文的 url 地址:

https://video.fuyeor.com/watch/扭曲变形的多边形_BUcGGofQj5TgfJn.html

需要进行 urlencode(转码)修改为这样才能正常识别爬取:

https://video.fuyeor.com/watch/%E6%89%AD%E6%9B%B2%E5%8F%98%E5%BD%A2%E7%9A%84%E5%A4%9A%E8%BE%B9%E5%BD%A2_BUcGGofQj5TgfJn.html

5、如果无法登录 Google search console,你也可以在 robots.txt 中加入站点地图的地址。

这样 Google、Microsoft Bing、Yandex 等等搜索引擎可以在无需提交 sitemaps 的情况下得知 sitemaps 的存在。

# 位于网站根目录下的 robots.txt 文件,例如 https://www.fuyeor.com/robots.txt
User-agent: *
Disallow: /m?
Allow: /zh-cn/
Disallow: /toolkit/apps/
Disallow: /manager/
Allow: /manager/website

# Sitemap 文件可以在其他二级域名网站下存放
# 如果有多个 Sitemap 位置,可以都写在 robots.txt 中,没有限制。

Sitemap: https://www.fuyeor.com/index/sitemap.xml
Sitemap: https://www.fuyeor.com/index/sitemaps.txt

参考

  1. ^文本格式的网站地图应该怎么写? https://docs.fuyeor.com/answer/10030.html