0%

Hexo写作必备技能

创建文章与删除

1
2
3
4
创建文章:
hexo new "文章title"
删除文章:
hexo remove "文章title"

插入图片

首先是修改配置,在根目录下的_config.yml文件中找到post_asset_folder: false替换为如下配置,保存

1
2
3
4
post_asset_folder: true
marked:
prependRoot: true
postAsset: true

更改好配置后,当用·hexo new "文章title"创建新文章时,会在文章存储目录_posts下生成一个与文章名相同的文件夹,把图片a.jpg放文件夹中,在需要插入图片处使用md插入图片写法

1
!['图片描述'](a.jpg)

这样hexo g解析后,hexo shexo d后预览,想要在vsCode侧边栏预览还有typora还得扩展其他方法,目前还没找到合适的

生成永久文章链接

安装Hexo-abbrlink插件

1
npm install hexo-abbrlink --save

修改根目录站点配置文件_config.yml,找到permalink:处修改以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
permalink: posts/:abbrlink.html     # 将原来文章的地址修改为这个

# 并添加如下配置:
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. false(default)
# Generate categories from directory-tree
# depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: true #true(default)
depth: #3(default)
over_write: false
auto_title: false #enable auto title, it can auto fill the title by path
auto_date: false #enable auto date, it can auto fill the date by time today
force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink. This only updates abbrlink rather than other front variables.
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks

进行hexo cleanhexo g会自动在你的文章内容头标签加上abbrlink: aaaa(aaaa代表随机代码),复制aaaa,在需要使用的地方插入aaaa,插入后hexo g永久链接会在文章末尾显示:

1
https://name.gitee.io/posts/aaaa/
-------------本文结束感谢您的阅读-------------