Hexo - How to add pictures

1. Modify post_asset_folder option of _config.yml to true

post_asset_folder: true

2. Mark off some code on ./node_modules/hexo-asset-image/index.js

// $('img').each(function(){
// if ($(this).attr('src')){
// // For windows style path, we replace '\' to '/'.
// var src = $(this).attr('src').replace('\\', '/');
// if(!(/http[s]*.*|\/\/.*/.test(src)
// || /^\s+\//.test(src)
// || /^\s*\/uploads|images\//.test(src))) {
// // For "about" page, the first part of "src" can't be removed.
// // In addition, to support multi-level local directory.
// var linkArray = link.split('/').filter(function(elem){
// return elem != '';
// });
// var srcArray = src.split('/').filter(function(elem){
// return elem != '' && elem != '.';
// });
// if(srcArray.length > 1)
// srcArray.shift();
// src = srcArray.join('/');

// $(this).attr('src', config.root + link + src);
// console.info&&console.info("update link as:-->"+config.root + link + src);
// }
// }else{
// console.info&&console.info("no src attr, skipped...");
// console.info&&console.info($(this));
// }
// }

3. Use Markdown / Hexo syntax in your post.md to show the picture

  1. Markdown Syntax
    ![Saber](saber.jpg)

Saber

  1. Hexo Syntax
    {% asset_img saber.jpg This is an example image %}

4. Don’t forget to rebuild your blog

hexo clean && hexo g && hexo s # show the blog in local server
hexo clean && hexo g && hexo d # deploy the blog