GitHub+Hexo博客网站搭建(四)

GitHub+Hexo博客网站搭建(四)

SEO(Search Engine Optimization),搜索引擎优化,让博客更容易被搜索引擎检索

文章链接优化

原本的文章链接有一长串,有年月日标题等,使用插件生成唯一文章链接

安装hexo-abbrlink插件

1
npm install hexo-abbrlink --save

配置_config.yml文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# permalink
permalink: posts/:abbrlink/
# or
permalink: posts/:abbrlink.html
# abbrlink设置,在后面添加
# abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32
rep: hex #support dec(default) and hex
drafts: false #(true)Process draft,(false)Do not process draft. false(default)
# Generate categories from directory-tree
# depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: true #true(default)
depth: #3(default)
over_write: false
auto_title: false #enable auto title, it can auto fill the title by path
auto_date: false #enable auto date, it can auto fill the date by time today
force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink. This only updates abbrlink rather than other front variables.

谷歌

站点地图

网站的sitemap需要提交到搜索引擎

安装sitemap插件

1
npm install hexo-generator-sitemap --save

可选配置_config.yml文件

1
2
3
4
5
6
7
8
9
sitemap:
path:
- sitemap.xml
- sitemap.txt
template: ./sitemap_template.xml
template_txt: ./sitemap_template.txt
rel: false
tags: true
categories: true

访问站点url加上sitemap.xml可查看站点地图

收录站点

查看站点是否被收录,谷歌搜索site:https://wangaaayu.github.io/blog/

登录谷歌站点控制台Google Search Console,添加站点,资源类型选择网址前缀,输入_config.yml文件中的url,选择HTML文件验证,下载文件后放入博客目录中的public文件夹下,并备份一份在根目录下,hexo d发布博客,点击验证即可完成

在谷歌站点控制台中选择站点地图,提交网站的站点地图

过段时间网站就可以被谷歌收录

参考

hexo博客进行百度、谷歌SEO - _吟游诗人 - 博客园 (cnblogs.com)

【Hexo实战】SEO(百度、Google)设置_51CTO博客_hexo seo

hexo之SEO优化 - 知乎 (zhihu.com)


GitHub+Hexo博客网站搭建(四)
https://wangaaayu.github.io/blog/posts/6d0c3408/
作者
WangAaayu
发布于
2023年6月2日
更新于
2023年6月8日
许可协议