zhonger / jekyll-theme-H2O-ac

🎉 A Jekyll theme for researchers and maintainers based on H2O theme.
https://h2o-ac.lisz.me
MIT License
39 stars 24 forks source link

Relative Path of Images failed to render in post. #17

Closed TangLongbin closed 7 months ago

TangLongbin commented 7 months ago

Description

While using relative path to insert a image in post, it will be failed to render after deployed.
But it works well in github and local computer.

Example

// post.md
!["fig"](./image/fig.png fig)
// This will failed to render in blog.
zhonger commented 7 months ago

I think this problem is related to the image markdown style (not related to the theme). Here are the styles I know.

!["fig"](./image/fig.png fig)   // Relative path
![fig](/image/fig.png)          // Absolute path
![fig](https://url.com/fig.png)  // Third-party URL

For Jekyll, I recommend the last two styles. _posts directory is only used for saving post.md file. The images should be stored in assets/img/ with absolute path /assets/img/.

According to my experience, storing all images in third-party object storage with CDN will be the best choice. After all, storage and loading speeds will be improved obviously.

TangLongbin commented 7 months ago

You’re right. I used absolute path /asset/img in other posts, and the images were shown in the right way.

The post for this issue is moved from one of my old posts. So I think I have to try third-party storage service as you suggested.

Thanks!