Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Font Awesome library in a Shopify store

I'm trying to use Font Awesome:

http://fortawesome.github.com/Font-Awesome/

I've used these font icons on several Rails projects with no problem but for some reason when I try to use them in a Shopify store they don't get rendered.

I'm using another @font-face with no difficulties but for some reason this @font-face is not rendering.

In assets/ I have:

fontawesome-webfont.eot
fontawesome-webfont.svg
fontawesome-webfont.ttf
fontawesome-webfont.woff

And I load them with @font-face just like I do with another font-face that works fine. in my stylesheet.css which lives in assets/

@font-face {
  font-family: "FontAwesome";
  src: url('fontawesome-webfont.eot');
  src: url('fontawesome-webfont.eot?#iefix') format('eot'), 
    url('fontawesome-webfont.woff') format('woff'), 
    url('fontawesome-webfont.ttf') format('truetype'), 
    url('fontawesome-webfont.svg#FontAwesome') format('svg');
      font-weight: normal;
      font-style: normal;
  }

But when I try to use the icons they can't seem to load. Any idea why this isn't working on Shopify? I feel like I'm missing something small but I can't figure it out.

like image 677
dylanjha Avatar asked Jun 30 '12 19:06

dylanjha


2 Answers

The simplest solution is to attach this to header of theme.liquid

<!-- Font-Awesome ================================================== -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">

No extra uploading. No installation. No hassle. Done.

Thank you MaxCDN :)

like image 114
gabchan Avatar answered Oct 13 '22 12:10

gabchan


You will want to use the liquid asset URL helper in your CSS. More docs on the asset URL helper can be found here https://shopify.dev/docs/themes/liquid/reference/filters/url-filters#asset_url

like image 34
John Duff Avatar answered Oct 13 '22 11:10

John Duff