https://www.cnblogs.com/huanhao/p/hexobase.html
Step.2 基本配置 - Theme Shoka Documentation - 二进制杂谈 - 计算机科学 | Yume Shoka = 有夢書架 = 吾乃天,壶中之天
Step.3 界面显示 - Theme Shoka Documentation - 二进制杂谈 - 计算机科学 | Yume Shoka = 有夢書架 = 吾乃天,壶中之天
【hexo 博客进阶】1.Markdown 语法 - huanhao - 博客园
路过图床 - 免费图片上传,专业图片外链,免费公共图床
# 注册域名
# 安装 proot 容器
# 安装 hexo
安装最新版 npm:(官网:https://deb.nodesource.com)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash - | |
sudo apt-get install -y nodejs |
安装 hexo:
npm i hexo-cli -g |
创建并进入博客文件夹:
mkdir blog | |
cd blog |
初始化 hexo:
hexo init |
可以启动 hexo 看一下效果:
hexo s |
打开 http://localhost:4000,就能看到网站了。(输入 ctrl+c 停止 hexo 进程)
# 安装 hexo pro 后台插件
hexo pro 是一个高效的 hexo 后台管理插件,可以让我们更方便地进行编辑文章等操作。
安装:
npm i hexo-pro --save |
输入 hexo s 启动 hexo 服务器后插件会自动启动,打开 http://localhost:4000/pro 进入 hexo pro 后台。
# 安装并配置主题
这里以 shoka 主题为例,想安装其他主题可以去 https://hexo.io/themes 自行找教程。
# 安装主题
apt install git nano chromium-browser build-essential -y | |
git clone https://github.com/amehime/hexo-theme-shoka.git ./themes/shoka |
# 安装依赖
npm un hexo-renderer-marked --save | |
npm i pangu --save | |
npm i hexo-renderer-multi-markdown-it --save | |
npm i hexo-autoprefixer --save | |
npm i hexo-algoliasearch --save | |
npm i hexo-symbols-count-time --save | |
npm i hexo-feed --save |
我使用 npm 同时安装这些依赖会出现内存不足的问题,所以这里逐个安装。如果出现报错重试几次即可。
# 配置依赖
# 修改站点配置文件
nano _config.yml |
找到 syntax_highlighter: highlight.js 这一行,删掉 highlight.js :
syntax_highlighter: |
找到 theme: landscape 这一行,把 landscape 改成 shoka :
theme: shoka |
在文件最后空行并添加如下内容:
markdown: | |
render: # 渲染器设置 | |
html: false # 过滤 HTML 标签 | |
xhtmlOut: true # 使用 '/' 来闭合单标签 (比如 <br />)。 | |
breaks: true # 转换段落里的 '\n' 到 <br>。 | |
linkify: true # 将类似 URL 的文本自动转换为链接。 | |
typographer: | |
quotes: '“”‘’' | |
plugins: # markdown-it 插件设置 | |
- plugin: | |
name: markdown-it-toc-and-anchor | |
enable: true | |
options: # 文章目录以及锚点应用的 class 名称,shoka 主题必须设置成这样 | |
tocClassName: 'toc' | |
anchorClassName: 'anchor' | |
- plugin: | |
name: markdown-it-multimd-table | |
enable: true | |
options: | |
multiline: true | |
rowspan: true | |
headerless: true | |
- plugin: | |
name: ./markdown-it-furigana | |
enable: true | |
options: | |
fallbackParens: "()" | |
- plugin: | |
name: ./markdown-it-spoiler | |
enable: true | |
options: | |
title: "你知道得太多了" | |
minify: | |
html: | |
enable: true | |
exclude: # 排除 hexo-feed 用到的模板文件 | |
- '**/json.ejs' | |
- '**/atom.ejs' | |
- '**/rss.ejs' | |
css: | |
enable: true | |
exclude: | |
- '**/*.min.css' | |
js: | |
enable: true | |
mangle: | |
toplevel: true | |
output: | |
compress: | |
exclude: | |
- '**/*.min.js' | |
autoprefixer: | |
exclude: | |
- '*.min.css' | |
algolia: | |
appId: | |
apiKey: | |
adminApiKey: | |
chunkSize: 5000 | |
indexName: blog | |
fields: | |
- title #必须配置 | |
- path #必须配置 | |
- categories #推荐配置 | |
- content:strip:truncate,0,2000 | |
- gallery | |
- photos | |
- tags | |
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" |