I'm trying to add google fonts to my Rails 5.2 application and I can't figure out why it doesn't work/what is missing:
i added the following lines in application.scss file :
@import url('://fonts.googleapis.com/css?family=Lato:400,700,900&display=swap');
body {
padding-top: 70px;
font-family: 'Lato', sans-serif;
}
Before using @import in application.scss i tried to add in application.html.erb the following line in the head
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,900&display=swap" rel="stylesheet">
Thanks for any help!
Importing it into my Rails app was pretty easy. First, you create a folder called 'fonts' in your 'assets' folder. After that, you go shopping for fonts! After downloading one that catches your eye, simply drag it to your fonts folder.
Google Fonts is a library of 1455 open source font families and APIs for convenient use via CSS and Android. The library also has delightful and beautifully crafted icons for common actions and items. Download them for use in your digital products for Android, iOS, and web.
It seems the first line in the application.scss, there's a colon ( before //fonts
, after url('
) that causes error. Removing this fixes it:
@import url('//fonts.googleapis.com/css?family=Lato:400,700,900&display=swap');
body {
padding-top: 70px;
font-family: 'Lato', sans-serif;
}
No need to add additional line into your application since it'll be compiled in your scss file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With