0%

Blog 4:[Hexo教程]Hexo之博文添加图片

请注意:本文参考了CSDN的有关教程。

博文美化小妙招(


启用post_asset_folder开关

站内配置文件_config.yml中,Ctrl + F搜索字段post_asset_folder,将其值设置为true。此操作将允许在hexo new "filename"时,在source/_posts/目录下创建同名文件夹,以管理博文中的各种附件。


# 安装hexo-asset-image插件
> 注意科学上网

在Hexo根目录下打开Git Bash,输入:bash~~ ~~npm install https://github.com/CodeFalling/hexo-asset-image --save~~ ~~
等待。
> 本机测试时,npm install hexo-asset-image --save无法实现上述功能,因而换用。读者可以自行尝试之。

注意
本条更新于8/8/25,hexo-asset-image 插件已经失效。换用 hexo-asset-img 插件。

安装hexo-asset-img插件

在 Hexo 根目录下打开 Git Bash,输入:

1
npm install hexo-asset-img --save

等待。

修改站点配置文件 _config.yml

1
2
3
4
5
post_asset_folder: true
marked:
prependRoot: true
postAsset: true
relative_link: false

在Markdown中引用图片

在博文中,引用图片的语法如下:

1
!["替换文本"](图片名称.扩展名 "描述文本")
  • 请注意:"替换文本""描述文本"是可选的。

  • 请将图片预先放在上述创建之同名文件夹下。

  • 只需填入图片名而无需填写路径。这是因为hexo-asset-image插件在Hexo将Markdown渲染为HTML时,会自动补全路径。

例如:

1
![title](image.jpg "description")

效果

效果

-------------本文结束 感谢您的时间-------------

欢迎关注我的其它发布渠道