hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.64k stars 4.87k forks source link

Image can't be displayed correctly #3395

Closed serend1p1ty closed 5 years ago

serend1p1ty commented 5 years ago

I am new to HEXO. My blog has a strange problem now: Images can't be displayed correctly, and the reason I have found is the images have incorrect path. According to the results I have found in Google, I got a solution:

  1. Set post_asset_folder = true

  2. Download a plugin using npm install https://github.com/CodeFalling/hexo-asset-image --save

  3. Using relative path in markdown like this ![](test.png)

But the problem of incorrect image path still haven't be solved, because I found there is a prefix in every image path. Just like this. fkmd98uf7np yjx oda kf2 What a strange prefix yoursite.com! Can anyone help me? I will be very grateful. Here is my configuration of HEXO.

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
deploy:
  type: git
  repository: git@github.com:GooCoder/GooCoder.github.io.git
  branch: master
serend1p1ty commented 5 years ago

Can anyone help me? I really need your help.

serend1p1ty commented 5 years ago

Thanks for your kindness.

aghontpi commented 5 years ago

i have problem with the image as well, image is being generate with the '/' infront of it. thus file not found error is thrown.

 <img src="/blog/2018/11/26/xxxx-xxx/tT.gif">

But it should be

 <img src="blog/2018/11/26/xxxx-xxx/tT.gif">

configs:

url: url/blog/
note here,  only the url is 'url/blog', but the folder structure is just root.
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: true
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
FengZhiheng commented 4 years ago

I have the same problem. Really need help

JoPatWa commented 2 years ago

Same here.... it generates with slashes in the wrong spots.