目的:搜索引擎收录网站

概念

站点地图:描述了一个网站的架构。

它可以是一个任意形式的文档,也可以是列出网站中所有页面的一个网页。

通常采用分级形式。

有助于访问者以及搜索引擎的机器人找到网站中的页面

安装

1
2
npm install hexo-generator-sitemap --save #sitemap.xml适合提交给谷歌搜素引擎
npm install hexo-generator-baidu-sitemap --save #baidusitemap.xml适合提交百度搜索引擎

配置

_config.yml

  • 在站点配置文件_config.yml添加以下代码
1
2
3
4
5
# 自动生成sitemap
sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml
  • 在站点配置文件_config.yml修改以下代码
1
2
3
4
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
## 比如网站地址是https://a.com,那么下面就写url: https://a.com
url: http://yoursite

编译

1
hexo g -d

会在/public下生成sitemap.xmlbaidusitemap.xml

收录

google

Search Console

  • 添加网站地址
  • 提交sitemap.xml

baidu

百度资源

  • 添加网站地址
  • 提交
    • 站点信息->网页抓取->详情