Github Pages cannot find my source in the repository

Asked

Viewed 48 times

0

I sent a website to Github Pages along with some fonts that will be used on the page. The directory structure is this:

MeuRepositorio/
    index.html
    public/
        ...
        fonts/
            MinhaFonte.TTF
        css/
            style.css

Inside the archive style.css, I use the code below to import the source:

@font-face {
  font-family: MinhaFonte;
  src: url(../fonts/MinhaFonte.TTF);
}

The problem is that Github Pages does not find the file and generates the following error:

Failed to load resource: the server responded with a status of 404 ()

And this error is very strange because, if I pass the cursor over the name of the font that should be loaded - MinhaFonte.TTF:1 - next to the error message, it shows the full URL and supposedly correct, that is this:

https://myName.github.io/MeuRepositorio/public/fonts/minhaFonte.TTF

What I’m doing wrong?

  • @Augustovasques Neither the relative URL nor the absolute URL is working. Have a look at my repository: https://github.com/JeanExtreme002/JeanExtreme002

  • @Augustovasques No. I’m not getting this. If I type in the browser bar the absolute URL https://jeanextreme002.github.io/JeanExtreme002/public/fonts/AutumnRegular.ttf the font is loaded and downloaded correctly, but within my site it does not happen. What I do then?

  • @Augustovasques I tried to use this absolute URL with the raw and the following error is generated: Access to font at 'https://github.com/JeanExtreme002/JeanExtreme002/blob/main/public/fonts/DeathRattleBB.ttf' from origin 'https://jeanextreme002.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested Resource.

  • And I searched the repository for JeanExtreme002/raw/main and he returned a 404.

  • @Augustovasques Yes, the font is loaded and downloaded into that URL, but only if I put it in the address bar. Inside the site, the error I showed up there is generated.

  • Yeah, take a look there.

  • @Augustovasques Yes, that’s the mistake he makes...

  • Now I get it, try https://jeanextreme002.github.io/JeanExtreme002/public/fonts/AutumnRegular.ttf

  • That’s what I tried the first time, that you had me put the absolute URL, and it didn’t work. It gave error 404.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.