You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用GitHub Pages托管网站时图片无法加载及二进制文件变更提示问题

Fixing Image Loading Issues on GitHub Pages with "This binary file is changed." Message

Hey there! I’ve run into this exact headache when setting up GitHub Pages before, so let’s break down what’s going on and fix those missing images. That "This binary file is changed." note on GitHub is a key clue—it means your image files (which are binary assets) were flagged as modified, but there’s likely a hiccup in how they were committed, referenced, or uploaded.

Here’s how to get your images loading properly:

1. Double-check your image file paths

  • Make sure all image references in your HTML/CSS use relative paths (not absolute local paths like C:\my-site\images\pic.jpg). For example, if your images live in an images folder at your repo’s root, use ./images/pic.jpg or just images/pic.jpg.
  • Watch out for case sensitivity! GitHub Pages treats Images/Pic.jpg and images/pic.jpg as two totally different paths. Match the exact folder and filenames from your local repo and GitHub.

2. Re-submit your binary image files

Sometimes GitHub Desktop can fumble with binary files. Try using the command line to re-add and commit them cleanly:

  1. Open your terminal and navigate to your repo folder:
    cd path/to/your/github/repo
    
  2. Add all image files (or specify individual ones if you prefer):
    git add images/*  # Replace with your actual image folder path
    
  3. Commit with a clear message to track the fix:
    git commit -m "Fix: Re-add binary image files to resolve loading issues"
    
  4. Push the changes up to GitHub:
    git push origin main  # Use "master" if that's your default branch name
    

3. Verify images are properly uploaded to GitHub

  • Head to your repo on GitHub, navigate to the folder with your images, and click on a problematic image. If it won’t preview on GitHub, the file didn’t upload completely. Delete the broken image from the repo, re-add it locally, then repeat the commit/push steps.

4. Trigger a GitHub Pages rebuild

GitHub Pages might be serving cached old content. Force a fresh build by:

  • Going to your repo’s Settings tab
  • Clicking Pages in the left sidebar
  • Temporarily switching the source branch (e.g., from main to master, then back to main)
  • Saving the changes—this will kick off a rebuild of your site

Wait a minute or two for GitHub Pages to update, then refresh your site at https://joaocadavez.github.io/—your images should load correctly now!

内容的提问来源于stack exchange,提问作者João Cadavez

火山引擎 最新活动