简 述: 在 Mac
重装的系统上,重新配置一遍 hexo + yun
的个人博客,这里记录一下 个人习惯 的一些 yun
主题的详细配置。
[TOC]
文件夹详细配置:
# 安装 node 和 hexo
brew search node # 直接安装最新的 14.xx,会有警告,安装 12.xx 版本即可
brew install node@12
echo 'export PATH="/usr/local/opt/node@12/bin:$PATH"' >> ~/.zshrc
node -v # node -v 验证安装成功 (12.18.3 LTS)
source ~/.zshrc
npm install -g hexo-cli
npm install hexo # hexo -v 验证安装成功
mkdir xmuliMark # 确保里面是空的,隐藏文件也没有
hexo init xmuliMark
cd xmuliMark
git init
git remote add origin git@github.com:xmuli/xmuliMark.git # git remote -v 验证设置成功
git clone -b master https://github.com/YunYouJun/hexo-theme-yun themes/yun # 后续升级使用 dev 分支
npm install hexo-render-pug hexo-renderer-stylus
# 配置 yun 主题细节
npm install hexo-generator-tag # 安装标签 tags : hexo-generator-tag
hexo new page tags # 生成之后替换
# ---------- 修改 source/tags/index.md 的 Front Matter ----------
---
date: 2017-10-09 19:11:58
comments: false
type: tags
---
# ---------- yun/_config.yml 设置如下 ----------
wordcloud: # 标签云(词云)
enable: true
height: 350
# 打赏二维码:替换文本即可 reward
# 编辑链接:替换文本即可 post_edit
# 运行时间:替换文本即可 live_time
# 关闭留言跳转 GitHub Issues:替换文本即可 Comments
npm install hexo-wordcount # 字数统计
# ---------- yun/_config.yml 设置如下 ----------
wordcount:
enable: true
count: true
time: true
npm install hexo-generator-search --save # 开启本地搜索
# ---------- yun/_config.yml 设置如下 ----------
local_search:
enable: true
src: /js/search/local-search.js
# 谷歌广告:替换文本,不开启 Google Adsense
# 谷歌搜索:替换文本即可 google_analytics
npm install hexo-prism-plugin # 代码高亮
# ---------- 💘 需要新增 💘 hexo/_config.yml 设置如下 ----------
prism_plugin:
mode: preprocess # realtime/preprocess
theme: default
line_number: false # default false
# custom_css: "path/to/your/custom.css" # optional
# 顺带关闭 hexo/_config.yml 自带的高亮
highlight:
enable: false
npm install hexo-generator-feed --save # RSS 安装
# ---------- yun/_config.yml 设置如下 (但我没有修改) ----------
social:
- name: RSS
link: /atom.xml # config.feed.path
icon: icon-rss-line
color: orange
npm uninstall hexo-generator-index --save # 文章置顶: 文章头部添加 top: true 即可
npm install hexo-generator-index-pin-top --save
npm install hexo-abbrlink --save # 文章短链接
# ---------- 💘 需要新增 💘 hexo/_config.yml 设置如下 ----------
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
# permalink: :year/:month/:day/:title/ # 旧的注释掉
# permalink_defaults: # 旧的注释掉
permalink: posts/:abbrlink/
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
# Generate categories from directory-tree
# depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: false #默认为 true, 手改改为 false
depth:
网页配置同步:
npm install hexo-deployer-git --save # 自动部署 hexo d 命令报错 ERROR Deployer not found: git 的解决方案
# 在 github 网页的 “settings-Secrets” 中,创建一个名为 HEXO_DEPLOY_KEY 的变量(下面脚本会用到),其值为本地机器的 git 私有秘钥( cat ~/.ssh/id_rsa 所输出的值); ==> 是私有秘钥,不是公有秘钥 <==
自动部署,在网页 Action
上创建文件 hexoDeploy.yml :
name: Hexo Deploy Automatically
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Node.js envs
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Hexo deploy
env:
HEXO_DEPLOY_KEY: ${{ secrets.HEXO_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$HEXO_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name "xmuli"
git config --global user.email "xmulitech@gmail.com"
npm i -g hexo-cli
npm i
hexo clean && hexo generate && hexo deploy
I don't rely on this for a living, but I would be encouraged if you donated.
- 本文链接:https://xmuli.tech/posts/1858a637/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。