站点地图和索引

1.自动生成站点地图,输入安装插件:

1
2
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save

2.配置_config.yml:

1
2
3
4
5
6
7
8
# 站点地图配置
sitemap:
path: sitemap.xml
template: ./sitemap_template.xml
rel: false

baidusitemap:
path: baidusitemap.xml

3.robots.txt配置
创建source/robots.txt:

1
2
3
4
5
6
7
8
9
10
11
12
13
User-agent: *
Allow: /
Allow: /archives/
Allow: /categories/
Allow: /tags/

# 禁止爬取管理页面
Disallow: /admin/
Disallow: /login/

# 站点地图
Sitemap: https://yourdomain.com/sitemap.xml
Sitemap: https://yourdomain.com/baidusitemap.xml

永久链接

1.hexo-abbrlink

在Hexo中,我们可以使用hexo-abbrlink插件,安装:

1
npm install hexo-abbrlink --save

不同算法和进制生成的值:

crc16 & hex
http://www.example.com/posts/66c8.html

crc16 & dec
http://post.example.com/posts/65535.html

crc32 & hex
http://post.example.com/posts/8ddf18fb.html

crc32 & dec
http://post.example.com/posts/1690090958.html

2.修改站点配置文件:

1
2
3
4
5
6
7
8
9
10
11
url: https://www.oneyangcrown.top/
permalink: posts/:abbrlink/
permalink_defaults:
pretty_urls:
trailing_index: true
trailing_html: true

# abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32
rep: hex #support dec(default) and hex