DEV Community

Zach Taylor
Zach Taylor

Posted on

2 1

How to Add Custom Fonts to a GatsbyJS Site

Today, I successfully added a custom font to a Gatsby site I'm working on. The process is pretty simple! Here it is in 4 steps:

1) Create a folder src/fonts/ and put your custom font files in it (mine was called Timeless.ttf).

2) Create a global CSS file at src/css/index.css.

3) In the global CSS file you just created, write the following:

@font-face {
  font-family: 'Timeless';
  src: url('../fonts/Timeless.ttf');
}

html {
  font-family: Timeless;
}
Enter fullscreen mode Exit fullscreen mode

4) In your gatsby-browser.js file, import the global CSS file.

import '.src/css/index.css'
Enter fullscreen mode Exit fullscreen mode

And there you go :)

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay