hexo-post-image
v1.0.0
Published
Fix image link generated by Hexo
Readme
hexo-post-image
Copyright © Tony's Studio 2025
A Hexo plugin to fix image URLs in the posts.
The Problem
If you store images alongside your markdown files in the source/_posts directory, you will probably turn on post_asset_folder: true in your _config.yml file. This will create a folder for each post to hold its images.
_posts/
post.md
post/
image1.pngHowever, when Hexo generates the site, it will put the images beside the post HTML files in the output directory, resulting in inconsistent relative paths.
public/
post/
post.html
image1.pngTo make images display correctly, you need to use ./image1.png in your markdown files. But in this way, you won't be able to preview the post in your markdown editor.
The Solution
There are some plugins that claim to solve the problem, but I found that they just don't work for me. So I wrote this simple plugin to fix the image URLs during the Hexo generation process.
