embedding an image using markdown in Hexo

  1. Installation
  2. Options

This approach should be the easist way to embed an image in a markdown file in Hexo.

hexo-renderer-marked 3.1.0 introduced a new option that allows you to embed an image in markdown.

Installation

Change to your Hexo blog directory, and run the following command in your terminal:

1
npm install hexo-renderer-marked --save

Options

To enable this plugin, edit _config.yml:

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

Once enabled, an asset image will be automatically resolved to its corresponding post’s path. For example, “image.jpg” is located at “/2020/01/02/foo/image.jpg”, meaning it is an asset image of “/2020/01/02/foo/“ post, ![](image.jpg) will be rendered as <img src="/2020/01/02/foo/image.jpg">.