一、Vercel
(一)创建博客
访问vercel
Create Git Repository -> Github
“REPOSITORY NAME”内输入希望的仓库名,勾选下面“Create private Git Repository”为创建私有仓库
点击“Go to Dashboard”
二、Hexo
(一)安装hexo
安装(Linux普通用户需要在前面添加sudo
,否则没有权限将链接到/usr/local/bin/
,会提示找不到命令)
npm install hexo-cli -g
拉取到本地
git clone git@github.com:cnlnn/blog.git
(二)配置hexo
1. 文章链接
npm install hexo-abbrlink --save
配置_config.yml
文件
permalink: posts/:abbrlink/
abbrlink:
alg: crc32 #算法: crc16(default) and crc32
rep: hex #进制: dec(default) and hex
2. 全文搜索
npm install hexo-generator-search --save
配置_config.yml
文件
# hexo-generator-search
search:
path: search.xml
field: post
3. RSS
npm install hexo-generator-feed --save
配置_config.yml
文件
feed:
enable: true
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
icon: icon.png
autodiscovery: true
template:
不配置默认为以下参数
# hexo-generator-feed
feed:
type: atom
path: atom.xml
4. 文章加密
安装
npm install hexo-blog-encrypt --save
配置_config.yml
文件
# hexo-blog-encrypt
encrypt:
enable: true
abstract: 这里有东西被加密了,需要输入密码查看哦。
message: 您好, 这里需要密码.
tags:
- {name: tagName, password: 密码A}
- {name: tagName, password: 密码B}
template: <div id="hexo-blog-encrypt" data-wpm="{{hbeWrongPassMessage}}" data-whm="{{hbeWrongHashMessage}}"><div class="hbe-input-container"><input type="password" id="hbePass" placeholder="{{hbeMessage}}" /><label>{{hbeMessage}}</label><div class="bottom-line"></div></div><script id="hbeData" type="hbeData" data-hmacdigest="{{hbeHmacDigest}}">{{hbeEncryptedData}}</script></div>
wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试.
wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
三、后续工作
(一)安装主题
git clone https://github.com/yelog/hexo-theme-3-hexo.git themes/3-hexo
cd themes/3-hexo && npm install
(二)SEO优化
1. hexo-generator-sitemap插件
npm install hexo-generator-sitemap --save
配置_config.yml
# hexo-generator-sitemap
sitemap:
path: sitemap.xml
rel: false
tags: false
categories: false
2. hexo-filter-nofollow插件
为外链添加rel="noopener external nofollow noreferrer"
属性
安装
npm install hexo-filter-nofollow --save
配置_config.yml
# hexo-filter-nofollow
nofollow:
enable: true
# 您希望插件继续运行的范围,可以是“站点”或“帖子”。默认值为site。
# 'post' - 仅将 nofollow 属性添加到您的帖子内容中的外部链接
# 'site' - 将 nofollow 属性添加到整个站点的外部链接
field: site
# 排除主机名。在适用时指定子域,包括www.
# 'exclude1.com' 不适用于www.exclude1.comnor en.exclude1.com。
exclude:
- 'exclude1.com'
- 'exclude2.com'
3. robots.txt
User-agent: *
Allow: /
Allow: /posts/
Disallow: /img/
Disallow: /js/
Disallow: /css/
Sitemap: https://cnlnn.ml/sitemap.xml
转载请注明来源,欢迎对文章中的引用来源进行考证,文章可能具有时效性,欢迎指出任何有错误、已失效或不够清晰的表达 ,可通过[邮件](mailto:cnlnnn@qq.com)联系垃圾堆主人