14

I'm running a site on Heroku, and having some troubles getting a google font to load.

My typography.sass file contains this:

@import url(http://fonts.googleapis.com/css?family=Bitter)

h1
  font-family: 'Bitter', Helvetica, serif

My production.rb file contains the lines:

config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true

My Gemfile includes:

gem 'rails_12factor', group: :production

I've gone through all the Heroku issues with the asset pipeline, and I've gotten all of my images and css files to load properly in production, but for whatever reason, the font only works in development.

oolong
  • 665
  • 6
  • 20
  • possible duplicate of [Heroku and Google Fonts](http://stackoverflow.com/questions/16948767/heroku-and-google-fonts) – rlemon Dec 16 '14 at 04:37

3 Answers3

15

I had the same problem and found this answer:

https://stackoverflow.com/a/18216759

It appears that Heroku wants https. So throwing in https solved the problem for me.

Community
  • 1
  • 1
ellerynz
  • 241
  • 2
  • 6
  • I just tried this and it didn't work for me. Do you have anything different from me in your config file? So far the only thing that works for me is to import the font in my application layout file. – oolong Sep 24 '13 at 14:54
  • 1
    We scrapped the project that initially created this question, but in a more recent project, using `@import url(//fonts.googleapis.com/css?family=Bitter)` was successful for us – oolong Jan 07 '15 at 18:41
4

I used to have the same issue but deleting the assets folder located in the public folder solved the problem for me. This will let Heroku precompile the css files for you and not use the files generate by running rake assets:precompile locally.

Ayman
  • 306
  • 2
  • 4
  • I made sure to do this as well, and it didn't make a difference for me. The font still wasn't being imported. – oolong Sep 24 '13 at 14:45
0

This fellow seemed to have a similar problem to yourself:

http://robert-reiz.com/2012/11/16/google-fonts-on-heroku/

Try his method of fixing it and see if that works. Good luck!