1

I'm having trouble to load an ttf and a woff file in Craft 3. I'm getting an error 500. The files exists and when trying to access it via the browser it shows: Twig Syntax Error – Twig_Error_Syntax Unexpected character "" for both of the files. Any suggestions ?

  • Instead of letting us guess what the issue might be it would be more useful to show us your code and your file structure. – Robin Schambach Mar 11 '18 at 21:33
  • Hey Robin, There is nothing fancy going on actually. Just have a css style which is loading ttf and woff files. The chrome debugger shows error 500 and when i'm opening the file in the browser twig shows an error Twig Syntax Error – Twig_Error_Syntax Unexpected character "". Can it be some htaccess or twig error settings error ? – nmsdvid Mar 12 '18 at 8:15
  • Most likely you didn't include them properly thus we need the code – Robin Schambach Mar 12 '18 at 8:24
  • This is how i'm loading the icon font: @font-face{ font-family:icomoon; src:url(54da533830dd0c1910ac66aa608c303a.eot); src:url(54da533830dd0c1910ac66aa608c303a.eot) format("embedded-opentype"),url(f1d29a50c6ddc22d39bd7e3f0e5ce345.ttf) format("truetype"),url(ee2c51fe7b99ae8ee7a1e64c6dcf77d7.woff) format("woff"),url(00f344a009ddb271ecd750817ffdeee1.svg) format("svg"); } – nmsdvid Mar 12 '18 at 8:27
  • Do you have your files directly next to your index.php`? Because that's where your code searches them – Robin Schambach Mar 12 '18 at 8:34
1

My issue was that the assets files were in the same folder as the twig template files. Moving the files to the web folder solved the issue.

  • Your issue was that your @font-face statement was wrong, it was instructing the browser to load the files from a location where they did not exist. – Seth Warburton Mar 14 '18 at 9:09
  • Nope, it was not a 404, its seems that Craft somehow wanted to render the file as a template. – nmsdvid Mar 14 '18 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.