# 博客
2023-06-21 19:08:52 本博客基于 Hexo 正式创建,并使用主题 Shoka
2025-03-07 01:04:26 更改主题并使用 ShokaX
记录自己
# Hexo
npm install -g hexo-cli | |
npm install hexo | |
# npx hexo <command> |
# Github 配置
# 配置身份密钥
登录 git 账号
git config --global user.name "user_name" # 填入 GitHub 用户名 | |
git config --global user.email "user_email" # 填入 GitHub 注册的邮箱 |
获取 SSH KEY
# 默认即可 | |
ssh-keygen -t rsa -C "user.email" |
C:\Users\username\.ssh\id_rsa.pub
公钥内容复制至 GtihubSSH and GPG keys
检测公钥设置是否成功
ssh -T git@github.com | |
# Hi username! You've successfully authenticated, but GitHub does not provide shell access. |
# 配置 Hexo
安装 git 插件
npm install hexo-deployer-git --save |
<root>\_config.yml
deploy: | |
type: 'git' | |
repository: git@github.com:username/username.github.io.git # git 仓库地址 | |
branch: master |
如果关于推送失败时,将
<root>\.deploy_git
文件夹删除即可
# 基础指令
初始化 hexo init
# 生成 public 文件夹 | |
hexo g | |
# 删除 public 文件夹 | |
hexo clean | |
# 开启本地服务器 http://localhost:4000/ | |
hexo s | |
# 推送至 Github | |
hexo d | |
# 创建文章 | |
hexo n '<title>' | |
# 禁用加载插件和脚本 | |
hexo --safe | |
# 将消息详细记录到终端和 debug.log 文件 | |
hexo --debug |
一键三连上传
hexo c && hexo g && hexo d
# 插件
目前安装的~
# 主题需要
# Markdown 渲染
# 先删除已安装的 Markdown 渲染插件 | |
npm un hexo-renderer-marked --save |
hexo-renderer-multi-next-markdown-it
npm i hexo-renderer-multi-next-markdown-it --save |
# css 加载器
npm install hexo-autoprefixer --save |
_config.yml
autoprefixer: | |
exclude: | |
- '*.min.css' |
# 搜索功能
npm install hexo-algoliasearch --save |
_config.yml
algolia: | |
appId: #Your appId | |
apiKey: #Your apiKey | |
adminApiKey: #Your adminApiKey | |
chunkSize: 5000 | |
indexName: #"shoka" | |
fields: | |
- title #必须配置 | |
- path #必须配置 | |
- categories #推荐配置 | |
- content:strip:truncate,0,2000 | |
- gallery | |
- photos | |
- tags |
# 文章统计
字数、阅读时间
npm install hexo-symbols-count-time |
# Feed
npm install hexo-feed --save-dev |
_config.yml
keywords: #站点关键词,用 “,” 分隔 | |
feed: | |
limit: 20 | |
order_by: "-date" | |
tag_dir: false | |
category_dir: false | |
rss: | |
enable: true | |
template: "themes/shoka/layout/_alternate/rss.ejs" | |
output: "rss.xml" | |
atom: | |
enable: true | |
template: "themes/shoka/layout/_alternate/atom.ejs" | |
output: "atom.xml" | |
jsonFeed: | |
enable: true | |
template: "themes/shoka/layout/_alternate/json.ejs" | |
output: "feed.json" |
# 功能类 (非必须)
# 隐藏文章
npm install hexo-hide-posts --save |
_config.yml 配置
# hexo-hide-posts | |
hide_posts: | |
# 可以改成其他你喜欢的名字 | |
filter: hidden | |
# 指定你想要传递隐藏文章的位置,比如让所有隐藏文章在存档页面可见 | |
# 常见的位置有:index, tag, category, archive, sitemap, feed, etc. | |
# 留空则默认全部隐藏 | |
public_generators: [] | |
# 为隐藏的文章添加 noindex meta 标签,阻止搜索引擎收录 | |
noindex: true |
在想要隐藏的文章里添加 hidden 标记
hidden: true
---
可以在命令行运行
hexo hidden:list
来获取当前所有的已隐藏文章列表
# 评论系统
Valine(LeanCloud)
Twikoo
npm install hexo-next-twikoo@1.0.3 |
# 这里是用来测试 Hexo&Theme
**点击折叠**
这是被隐藏的内容