Hexo’s built-in asset mechanism is hard to use. This post shows how to painlessly insert images when editing Hexo posts with Typora.
Typora
In Preferences:
File structure:
1 | hexo/ |
In some-post.md
:
1 | ![alt](some-post/image.png) |
Hexo
In hexo/_config.yml
1 | post_asset_folder: true |
In hexo root folder:
1 | npm install --save hexo-asset-link |
In node_modules/hexo-asset-link/index.js
:
1 | // strip domain |
This will generate absolute paths for the images in rendered HTML (instead of relative path), which is useful when contents of a post are also displayed from the homepage (which lies in a different folder).