Hexo中插入图片
安装图片插件
hexo-renderer-marked
1
npm install hexo-renderer-marked --save
根目录的
_config.yml
文件中配置:1
2
3
4post_asset_folder: false // 这个考虑再三还是关上了,开启后会默认创建同名文件夹,但不是每个文档都有图片,笔者建议是false,导入图片的时候typora也会提示自动创建文件夹
marked:
prependRoot: true
postAsset: true创建文章,此时会在
source/_posts
生成同名文件夹,放置文章资源1
hexo n "xxx"
配置Typora
打开typora的偏好设置,点击图像,更改为如下设置
图片引入
注意:在typora中图片引入的格式:(引入第六步的插件以后,typora图片格式的文字不能显示了)
{% asset_img "image.jpg" "" %}
在hexo中图片引入的格式:

安装插件
hexo-image-link
解决typora与hexo路径不一致问题,这样在typora和hexo都可以显示图片了1
npm install hexo-image-link --save
typora中的图片在进行缩放的时候,会自动转为html格式,此时img的src不会发生自动转换,针对这种情况,暂时的解决办法是将图片上传到图床,把图片链接变为绝对路径,作者使用的图床是SMMS
Hexo-Next支持数学公式
卸载原有渲染器
hexo-renderer-marked
,安装hexo-renderer-kramed
1
2npm uninstall hexo-renderer-marked
npm install hexo-renderer-kramed配置Next的
_config.yml
文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17math:
# Default (true) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in Front-matter.
# If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
per_page: true
# hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
mathjax:
enable: true
# See: https://mhchem.github.io/MathJax-mhchem/
mhchem: false
# hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) required for full Katex support.
katex:
enable: false
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: false解决语义冲突
取消反斜杠
\\
和下划线_
的转义,/node_modules/kramed/lib/rules/inline.js
修改如下:1
2
3
4
5//escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
escape: /^\\([`*\[\]()#$+\-.!_>])/, //第11行
//em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, //第20行注意:em中对下划线进行了转义,但是对latex中的
*
没有处理,所以latex中*
需要全部用\ast
代替。在需要使用LaTeX渲染的博文中,在文章的Front-matter里打开mathjax开关:
1
mathjax: true
使用
行内公式
1
$lim_{1\to+\infty}P(|\sum_i^nX_i-\mu|<\epsilon)=1, i=1,...,n$
$lim_{1\to+\infty}P(|\sum_i^nX_i-\mu|<\epsilon)=1, i=1,…,n$
行间公式
1
$$lim_{1\to+\infty}P(|\sum_i^nX_i-\mu|<\epsilon)=1, i=1,...,n$$
公式编号
1
2
3
4
5
6\begin{align}
a+b\\
b+c\\
a+c\\
\end{align}
\label(52)\begin{align}
a+b\\
b+c\\
a+c\\
\end{align}
搭配typora
偏好设置
$\Rightarrow$MarkDown
$\Rightarrow$内联公式开启
$\Rightarrow$重启Typora
点击段落,公式块可以输入公式
Hexo生成唯一永久文章链接
hexo的文章链接默认的生成规则是::year/:month/:day/:title
,标题如果是中文,会变得特别冗长。同时修改标题后文章链接会发生变化,URL层级深,不利于SEO,因此安装如下插件。
安装
hexo-abbrlink
1
npm i hexo-abbrlink --save
修改根目录的
_config.yml
配置:(posts/
可以舍去)1
permalink: posts/:abbrlink/
清除hexo缓存
1
hexo clean
Hexo文章添加评论
登录Github,点击右侧头像,点击Setting选项
左侧菜单选择Developer setting,进入开发者页面
选择OAuth创建应用
设置应用的相关信息
- Application name 应用名称
- Homepage URL 博客主页
- Authorization callback URL 授权回调页面(同 Homepage URL)
保存 Client ID 和 Client secrets
配置主题
_config.yml
文件1
2
3
4
5
6
7
8
9
10
11
12gitalk:
enable: true
github_id: jin-lin0 # GitHub repo owner
repo: jin-lin0.github.io # Repository name to store issues
client_id: xxx # GitHub Application Client ID
client_secret: xxx # GitHub Application Client Secret
admin_user: jin-lin0 # GitHub repo owner and collaborators, only these guys can initialize gitHub issues
distraction_free_mode: true # Facebook-like distraction free mode
# Gitalk's display language depends on user's browser or system environment
# If you want everyone visiting your site to see a uniform language, you can set a force language value
# Available values: en | es-ES | fr | ru | zh-CN | zh-TW
language: zh-CN- 设置
enable
为true
github_id
填入github
帐号repo
填入github
仓库名(仓库名不是仓库地址),评论以issues
形式保存在该仓库下client_id
填入注册生成的值client_secret
填入注册生成的值admin_user
填入github
帐号,初始化评论账户
- 设置
隐藏评论功能,在front matter中添加:
1
comments: false
Github登录后访问文章,即可自动初始化gitalk的issues,成功添加后效果如下:
Hexo字数统计与阅读时长
根目录安装插件
hexo-symbols-count-time
1
npm install hexo-symbols-count-time --save
根目录配置
_config.yml
,如果中文较多awl
采用2,否则默认即可1
2
3
4
5
6
7
8
9symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
exclude_codeblock: false
awl: 2
wpm: 300
suffix: "mins."symbols
:字数统计time
:时间统计total_symbols
:总字数统计total_time
:总时间统计exclude_codeblock
:排除代码块计算主题配置
_config.yml
1
2
3
4symbols_count_time:
separated_meta: true
item_text_post: true
item_text_total: trueseparated_meta
:是否和发表时间不在一行item_text_post
:文章前面是否显示文字描述(本文字数,统计时长)item_text_total
:页面底部显示站点总字数,总时长清除hexo缓存
1
hexo clean
Hexo中插入背景音乐
网易云音乐中点击生成外链链接
复制外链iframe到
/next/layout/macro/sidebar.swig
中即可生成我的音乐自定义的歌单的外链播放器需要先分享到自己的动态
点进分享的动态,点击生成外链播放器就可以了
Hexo中隐藏文章
根目录安装插件
hexo-hide-posts
1
npm install hexo-hide-posts --save
根目录添加配置
1
2
3
4
5
6
7
8
9
10
11# hexo-hide-posts
hide_posts:
# font-matter中的过滤关键字
filter: hidden
# 指定你想要传递隐藏文章的位置,比如让所有隐藏文章在存档页面可见
# 常见的位置有:index, tag, category, archive, sitemap, feed, etc.
# 留空则默认全部隐藏
public_generators: []
# 为隐藏的文章添加 noindex meta 标签,阻止搜索引擎收录
noindex: true文章的
Font-Matter
中添加hidden: true
即可隐藏,但仍可通过链接访问控制台输入
hexo hidden:list
可以查看隐藏的文章列表1
2
3
4
5source: _posts/实用网站收集.md
slug: 实用网站收集
title: 实用网站收集
date: Mon Nov 06 2023 01:56:45 GMT+0800
updated: Sun Nov 19 2023 00:51:06 GMT+0800
Hexo配置canvas-nest背景
在
hexo/source/_data
目录下新建文件footer.swig
1
2
3{%- if theme.canvas_nest %}
<script type="text/javascript" color="0,0,255" opacity='0.5' zIndex="-2" count="50" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
{%- endif %}主题配置文件开启自定义footer.swig,同时配置
canvas_nest
开启1
2
3
4
5
6
7
8
9
10
11custom_file_path:
#head: source/_data/head.swig
#header: source/_data/header.swig
#sidebar: source/_data/sidebar.swig
#postMeta: source/_data/post-meta.swig
#postBodyEnd: source/_data/post-body-end.swig
footer: source/_data/footer.swig
#bodyEnd: source/_data/body-end.swig
#variable: source/_data/variables.styl
#mixin: source/_data/mixins.styl
style: source/_data/styles.styl1
canvas_nest: true