You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Markdown图片突然无法显示,求原因及恢复方法

Troubleshooting Missing Images on GitHub Pages

Hey there, let's break down why your images suddenly stopped showing up on your GitHub Pages, and walk through how you can get them back.

Common Causes & Fixes

1. Repository Visibility Changed to Private

If you recently switched your repository from public to private, that's almost certainly the issue. GitHub blocks public access to raw files in private repositories—even if your GitHub Pages site is public, the raw.githubusercontent.com links can't pull content from a private repo anymore.

Fixes:

  • Switch your repository back to public (go to your repo → Settings → General → Repository visibility → select "Public").
  • Or, replace the raw URLs with relative paths. Instead of using the full raw link, use something like:
    ![handleWheel](/images/handleWheel.png)
    
    GitHub Pages serves content directly from your repo's root, so relative paths are more stable and avoid permission issues entirely.

2. File/Path Name Changes or Case Sensitivity

GitHub's file system is case-sensitive, even if your local machine isn't. If you accidentally renamed the image (e.g., HandleWheel.png instead of handleWheel.png) or moved the images folder, the link would break.

Fixes:

  • Navigate to your repo's master branch (since your link points to master) and check the images folder: confirm handleWheel.png exists with the exact same spelling and case.
  • If the file was moved or renamed, update your Markdown link to match the new path/name.

3. Default Branch Changed from master to main

Many repos have switched from master to main as the default branch in recent years. If you renamed your default branch but didn't update the raw URL, the link would point to a branch that no longer exists (or isn't the one hosting your GitHub Pages content).

Fixes:

  • Check your repo's default branch (Settings → Branches → Default branch). If it's main, update your raw URL to use main instead of master:
    ![handleWheel](https://raw.githubusercontent.com/bask185/State-Machine-Scripts/main/images/handleWheel.png)
    
  • Again, using relative paths avoids this problem entirely since you don't have to specify the branch.

4. Accidental File Deletion

It's easy to accidentally delete files when cleaning up or merging branches. Double-check that handleWheel.png is still present in the images folder of the branch your GitHub Pages is using.

Fix:
If the file was deleted, restore it from your repo's commit history: go to the images folder in GitHub, click "History", find the commit where the file was present, and restore it.

Final Tip

Using relative paths for images in GitHub Pages is always the most reliable approach—it avoids issues with branch names, repo visibility, and raw URL changes. So replacing all those raw.githubusercontent.com links with simple relative paths will save you headaches down the line.

内容的提问来源于stack exchange,提问作者bas knippels

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:04:07