Hexo_本地图片如何上传到Github

第一步

  • 首先进行配置文件的修改, _config.yml(不是主题配置文件)
    1
    post_asset_folder: true
    修改配置项

    第二步

    1
    npm install hexo-asset-image --save
    install

    第三步

  • 通过命令,创建一篇新的文章时候,自动在source/_post/新建对应文件名称的文件夹(为了避免有时候文章中并没有图片,可以手动创建md文件,需要图片在创建文件夹即可)
    1
    hexo new test.md
  • 进入source/_post/下即可看到对应创建的文件和文件夹

    第四步

    1
    2
    3
    hexo clean  #清除
    hexo ge #生成静态资源 , 此时可以通过输出信息看到对应的图片名称信息,基本就完成了
    hexo s #本地查看是否生效

    注意

  • 在md文件中,图片的路径可以写一下两种方式都可以load到图片的路径
    1
    2
    ![test1](./1.png)
    ![test1](./test/2.png)
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

请我喝杯咖啡吧~

支付宝
微信