I'm currently working on incorporating webfonts into a Jekyll build. Interestingly enough, the fonts show up perfectly fine when I view them locally, but once I push my project to a live environment, the fonts mysteriously disappear. To make matters worse, the console spits out an error message saying
Failed to load resource: the server responded with a status of 404 ()
for each missing font.
The _site
directory has the following structure:
assets/css/style.css
fonts/ <-- all my .woff files are located here
index.html
Inside the index.html
file, the CSS file is referenced like this:
<link rel="stylesheet" href="{{ '/assets/css/style.css' | relative_url }}">
This is how the @font-face declaration looks like:
@font-face {
font-family: 'My font';
src: url('../../fonts/myfont.woff2') format('woff2'),
url('../../fonts/myfont.woff') format('woff');
}
Should I include any specific configurations in the _config.yml
file to ensure that the webfonts display correctly?