安装 Hexo
1 2
| yarn global add hexo-cli
|
初始化
1 2 3 4 5 6 7 8 9 10 11
| mkdir wiki && cd wiki hexo init
git clone https://github.com/zthxxx/hexo-theme-Wikitten.git themes/Wikitten
yarn add hexo-autonofollow hexo-directory-category hexo-generator-feed hexo-generator-json-content hexo-generator-sitemap
cp -rf themes/Wikitten/_source/* source/ cp -rf themes/Wikitten/_scaffolds/* scaffolds/ cp -f themes/Wikitten/_config.yml.example themes/Wikitten/_config.yml
|
主题配置
hexo 一般有两个配置文件需要修改,一个是主题相关的 (theme/<theme_name>/_config.yml),一个是站点相关的 (_config.yml)。
首先是主题相关的,这个大部分使用默认配置即可,主要修改需要修改的有profile和history_control中关于个人信息的东西。
而站点相关的,则需要修改比较多东西:
- 修改
theme为Wikkten
- 设置站点信息(如
title,subtitle等)
- 配置
url和permalink
- 配置
deploy,但是因为准备部署到vercel中,所以好像没太大必要配置。
- 然后就是一些插件的配置了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
marked: gfm: true
jsonContent: meta: false pages: title: true date: true path: true text: true posts: title: true date: true path: true text: true tags: true categories: true ignore: - 404.html
sitemap: path: sitemap.xml
nofollow: enable: true exclude: - wiki.codeand.fun
auto_dir_categorize: enable: true force: true
|
部署到 vercel
创建github仓库,并把wiki相关文件push上去。
1 2 3 4 5 6 7 8 9
| git init git add .
rm theme/Wikkten/.git
sed -e '/_config.yml/d' theme/Wikkten/.gitignore git commit -m "init wiki" git remote add origin git@github.com:wuxiaobai24/wiki.git git push -u origin master
|
然后在vercel中导入对应的仓库,并选择hexo作为环境即可,使用默认配置就能直接部署了。
如果需要配置自己域名的话,需要在vercel添加自己的域名,然后给域名添加一个 CNAME 类型执行cname.vercel-dns.com。
如果你是用CloudFlare的话,还需要进行一些额外配置,具体细节可以看 vercel 给出的方案 - How do I use a Cloudflare domain with Vercel?。
简单来将就是,将CloudFlare的 DNS 配置修改成不代理的,即“仅限DNS”。
跳过某些文件的渲染
在站点的_config.yml中有skip_render可以实现跳过渲染:
1 2 3 4
| skip_render: - "_posts/.obsidian/*" - "_posts/.stfolder/*" - "_posts/template/*"
|
文章加密
1
| npm i -s hexo-blog-encrypt
|
1 2 3 4 5 6 7 8
| encrypt: abstract: Here's something encrypted, password is required to continue reading. message: Hey, password is required here. tags: - {name: Daily, password: password} wrong_pass_message: Oh, this is an invalid password. Check and try again, please. wrong_hash_message: Oh, these decrypted content cannot be verified, but you can still have a look.
|