需求场景
基于Hexo
默认模板
在vscode中依次执行一下命令
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server
资源目录结构如下:
运行后的页面如下:
主题配置
以https://github.com/Shen-Yu/hexo-theme-ayer为例
配置详见官网地址
这里只是搬运一些重点。
安装
#国内用户如果速度较慢,可以把github地址替换为:https://gitee.com/mirrors/ayer.git
git clone https://github.com/Shen-Yu/hexo-theme-ayer.git themes/ayer
修改
将博客根目录下的 _config.yml
里的 theme
值修改成 ayer
theme: ayer
插件(必需)
npm install hexo-generator-searchdb --save
然后将以下配置复制到你博客根目录下的 _config.yml 里(注意不是ayer目录下的)
# hexo-generator-searchdb
search:
path: search.xml
field: post
format: html
hexo-generate-feed 用于生成RSS订阅
npm install hexo-generator-feed --save
然后将以下配置复制到你博客根目录下的 _config.yml 里(注意不是ayer目录下的):
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
资源目录如下
ayer主题目录下的 _config.yml文件配置
发布
以github为例
- 首先要安装 hexo-deployer-git 执行一下命令
npm install hexo-deployer-git --save
- 配置博客目录下的_config.yml
deploy:
type: git
repo: git@xxx.github.xxx/xxx.github.io.git # 你的github地址
branch: master
- 执行发布命令
hexo deploy
- 结果
问题
Q:不能及时更新配置内容
A:有一些配置项是需要执行hexo clean
命令才能刷新,猜测有一些内容存在了数据库里不是静态数据。
Q: hexo : 无法加载文件 C:\Users\xxxx\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkI
所在位置 行:1 字符: 1
- hexo init
-
+ CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
A:以管理员身份运行powershell
执行
set-executionpolicy remotesigned
输入y即可
[Y] 是(Y) [N] 否(N) [S] 挂起(S) [?] 帮助 (默认值为“Y”):