简体   繁体   中英

Assets not found on GitHub Pages Jekyll Blog

I am using the minima theme for jekyll. I want to add images to my posts. In _config.yaml I have baseurl set to /blog and url set to https://mywebsite.com because my jekyll blog is a separate repo that is accessed by mywebsite.com/blog. In the post I want to include the picture in I have

<figure>
  <img src="{{ site.baseurl }}/assets/pihole.png" alt="PiHole Dashboard"/>
  <center><figcaption>PiHole Dashboard.</figcaption></center>
</figure>

This works fine on my local, but when deploying to github pages the picture is not there. I can access mywebsite.com/blog/assets/main.css no problem, but when I try to access the image it gives me a 404.

Inspecting the page shows me that it does have the correct location

figure>
  <img src="/blog/assets/pihole.png" alt="PiHole Dashboard" />
  <center><figcaption>PiHole Dashboard.</figcaption></center>
</figure>

Is there something I am missing that is not uploading my image file to GitHub Pages?

需要在我的根目录中创建一个资产文件夹并将文件放在那里。

<figure>
  <img src={{ "/assets/pihole.png" | relative_url }} alt="PiHole Dashboard"/>
  <center><figcaption>PiHole Dashboard.</figcaption></center>
</figure>

Try relative_url as in Kitty image is missing in 'Welcome to Jekyll' post but shown at index.md and about.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM