Photos won't load and links are dead

2019-08-28 14:50发布

问题:

So I hosted my website on netlify with my github repo. All of my photos and files used in the site are there but they will not load. Only my index.html and style.css that is outside of all of the folders will load. I have a link to my github repo. Github Repo

html{
  background-color:#abb2bc;
}

body{
  margin:0;

}
h1 {
  margin:0;
  background-color: #363b42;
}
img{
  width:250px;
}

.navbar{
  text-align:center;
}

.blogpost{
  background-color:white;
  padding:5%;
  margin:3%

}

#blogheader{
  margin-top:15px;
}

.blogimage{
  margin-top:25px;
}
<!DOCTYPE html>
<html>

<head>
  <title>GamingCoachBlog</title>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
  <header>
      <div class="navbar">
        <h1>GamingCoach</h1>
      </div>
  </header>
  <main>
    <div class="blogpost">
      <h2 id="blogheader">Recent Blog Posts</h2>
      <a href="/Users/david/Desktop/Blog/Articles/Ten Fortnite Tips For Season 8/index.html"><img class="blogimage" src="C:/Users/david/Desktop/Blog/Images/How to get more wins in Fortnite.png" alt="How to get more wins in Fortnite"></a>
    </div>
  </main>
</body>

</html>

回答1:

'C://' refrences, or local refrences, do not work online. Aside from this, using spaces in your webpage name and file name is not recommended, as some browsers may not support spaces or will convert them to the web standard, a '+', or the unicode standard for space (U+0020) so that more actions can be performed on them.

FIX:

Swap
src="C:/Users/david/Desktop/Blog/Images/How to get more wins in Fortnite.png"
with
src="Images/How to get more wins in Fortnite.png"

to fix your problem and render the photo correctly, assuming your browser doesn't object to the spaces.