4

I uploaded my project to Github pages and the font doesn't work! I've read other questions about the issue that lead me to think I need to change how I'm pointing the file, but I can't sort it out.

Here's my @font-face:

@font-face {
    font-family: headerFont;
    src: url(fonts/FreePixel.ttf);
}

Here's my file structure:

Portfolio/
    index.html
    css/
        styles.css
        fonts/
            FreePixel.ttf
Rokitar
  • 191
  • 2
  • 12

1 Answers1

5

Try with a relative path, meaning starting with ./

src: url(./css/fonts/FreePixel.ttf);

That will check from which root folder GitHub page is considering that relative path.

Of course, that supposes the files are uploaded, and not (as it was the case) in the .gitignore file of the repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Just tried! When I use `./css`, my local page can't even read the font. I need to use `../css` but that doesn't seem to be read by Github pages. :( – Rokitar May 25 '17 at 04:58
  • @EmilyRobyn and ..//css/... ? – VonC May 25 '17 at 04:59
  • 1
    And that font is uploaded/present on the remote site? – VonC May 25 '17 at 05:14
  • WOW. for some reason my fonts folder was in my .gitignore. I didn't check there! Okay, your solution does work. Thank you so much! – Rokitar May 25 '17 at 05:22