Google Fonts

:discourse2: Summary Google Fonts is a simple theme component that allows you to add a font from Google Fonts without writing any CSS.
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-google-font-component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

This component allows you to set the main site font, and optionally separate fonts for headlines and monospaced text (code blocks). You can also choose a font weight in each case, and increase the font size.

Behind the scenes this sets up a little bit of CSS along with Google’s font <link>. Note that this is relying on Google to serve the font files from https://fonts.googleapis.com/.

Settings

Name Description
fonts Add the name of the font(s) you want to use from fonts.google.com. Note that font names are CaSe SeNsiTivE!
body font The main font used throughout Discourse, must be included in “fonts” setting above
body font weight Font thickness in the range of 100-900. 400 is normal, 700 is bold
headline font Optional font for headlines, must be included in “fonts” setting above
headline font weight Font thickness in the range of 100-900. 400 is normal, 700 is bold
monospaced font Optional font for code blocks, must be included in “fonts” setting above.
monospaced font weight Font thickness in the range of 100-900. 400 is normal, 700 is bold
normal font size Default font size for all users, adjusting this will adjust all font sizes proportionately
smaller font size Selectable in each user’s interface preferences
larger font size Selectable in each user’s interface preferences
largest font size Selectable in each user’s interface preferences

:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @awesomerobot 2025-03-14T15:46:34Z

Check documentPerform check on document:
48 Likes

This Fantastic! Can this be installed Multiple Times to link to different themes by changing it’s Name in Advanced install?

I don’t see why not. We’ve installed the same theme twice, for example here on Meta to have both a light and dark version.

3 Likes

Thanks. Forgot you can rename it to identify/link it to other themes.

1 Like

Thank you. I love it. :grin:

3 Likes

Thanks :heart: I really love it.

I just discovered that this component does not work for /pub/ (published) pages. The fonts are not loading on these pages resulting in a default Times New Roman alike font.

1 Like

I’m seeing default fonts as well, but on the

https://yoursite.org/u/activate-account/... activate account page

I tried and this is indeed an issue.

The published page tries to load the google font through the theme component:

image

The font file not being loaded on the published page, it doesn’t fall back to the font-family variable `Arial, sans-serif and uses Times New Roman instead.

There may be room for improvement here as long as the published pages can access the modifications required.

1 Like

To be honest ever since this discovery I define my fonts in custom CSS. Works great.

2 Likes

That’s awesome, thank you and your team for developing such a convenient feature ^^. I will recommend it to people I know who are using discourse to build user communities.

Quick bug report: I just noticed when I set the font weight then bold text doesn’t show up as bold.

I tested this with the fonts Work Sans and Zilla Slab. I changed the font weight from the default (400) to 300. When I did this bold text did not appear bold. Reset that setting and the bold text reappears.

I set it to 400 and called it a day, but wanted to let you know.

Thanks for your work on this!

Any way to get into the nitty gritty a little more? The “Headline” font is coming up as 900 weight by default with Headers inside of Topics. Would be great to set the defaults for each of those Markdown objects.

1 Like

There seems to be a bug with this, at least on my forum, if I add the font “Inter” with this component then the following happens:

  • Start editing or composing a message
  • Switch apps to something else while composer is open
  • Come back, and the zoom is all wrong, like it’s too far zoomed in
  • There will also be bugs with Chat and with scrolling now

Not sure if it happens with other fonts, but it happens 100% of the time if I add this component to any theme.

Is this a known bug? Is there a fix?

Thanks

2 Likes

We have Inter already built-in if you want to change the Base font and Heading font under admin > site settings, no component necessary

2 Likes

Which version of Discourse? Am on 3.3 stable and don’t see Inter. Having the same problems as some of the users here with this component.

I am on 3.3 and want to use Inter. While the font loads, BOLD text isn’t bold.

You’ll need to update to 3.4 for the built-in Inter option

2 Likes

I’ve just merged a refactor of this component that better aligns with Google Font updates — this should fix some issues people were having with different weights not appearing.

Note that the setting formatting changed slightly so that weights can no longer be included in the font name setting like Roboto:300,300i,500, and this would have to be updated to a simple Roboto… but it should migrate automatically on update.

1 Like