how to insert pictures in hexo

在部署好hexo后,使用hexo-asset-img脚本,一直无法在网页上访问图片。折腾了一下,改用hexo-renderer-marked.

hexo-asset-img问题,已经archived?弃用?

  1. hexo g会出现图片资源路径被链接到类似于 //.com/image.png 的地址
  2. 在网页端,md指向的image路径无法被正确展开

使用hexo-renderer-marked

  1. 安装
1
sudo npm install hexo-renderer-marked --saved
  1. hexo _config.yal修改为:
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
post_asset_folder: true
# hmr add start
marked:
gfm: true
pedantic: false
breaks: true
smartLists: true
smartypants: true
quotes: '“”‘’'
modifyAnchors: 0
anchorAlias: false
autolink: true
mangle: true
sanitizeUrl: false
dompurify: false
headerIds: true
lazyload: false
figcaption: false
prependRoot: true
postAsset: true
external_link:
enable: false
exclude: []
nofollow: false
disableNunjucks: false
descriptionLists: true
# hmr add end
  1. post_asset_folder: true 表示使用hexo new 一个新的blog时,会同时创建一个文件夹

  2. 把想要的贴在博客的图片放入对应的文件夹,然后使用下面这种语法(正常markdown语法),即可显示图片

1
![]()
  1. 贴出这篇博客的一些图片
    文件树