hexo的SEO优化是一件比较头疼的事情,因为他不像WordPress之类的那样一个插件解决,本文就给大家带来hexo生成sitemap站点地图的教程。
安装sitemap插件
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save
添加生成sitemap的配置文件
打开:/_config.yml
在文档末尾添加以下代码
1
2
3
4
|
# 自动生成sitemap
sitemap:
path: sitemap.xml
baidu: baidusitemap.xml
|
修改站点url配置文件
打开:/_config.yml,找到如下代码块
1
2
3
4
5
6
|
# URL
## If your site is put in a subdirectory, set url as ‘http://yoursite.com/child’ and root as ‘/child/’
url: http://www.leiouflying.cc
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
|
在url: http://www.leiouflying.cc
这一行填写您的站点url地址
hexo g
之后hexo编译的时候会自动在根目录生成站点地图
使用单独的百度站点地图的必要性
很多朋友觉得不做国外国内流量分流,就没有必要做两个sitemap文件,其实这是错误的,仔细观察会发现,”baidusitemap.xml”和”sitemap.xml”其实是不一样的,使用两个不同的sitemap文件更利于百度对您的站点的抓取,而”sitemap”则是除百度以外其他搜索引擎通用的了。