In my HTML file I put: <link rel="preload" href="/fonts/montserrat-v26-latin-italic.woff2 " as="font" type="font/woff2" crossorigin="">
I then saved, refreshed my site, viewed the page source and clicked the /fonts/montserrat-v26-latin-italic.woff2 URL, which brought me to: https://forums.mysite.com/fonts/montserrat-v26-latin-italic.woff2
I was met with a “404 Not Found” Nginx page. I thought, “oh wait, I don’t have a fonts folder on my Discourse directory on my VPS.” Thought it was weird that it didn’t just pull it from the fonts folder in my theme, though. So, I added a “fonts” folder at /var/discourse/shared/standalone/. Put my font file in there, refresh browser page again still a 404 error. Can I simply add folders to Discourse like this or do I need to relaunch my server for it to take effect or what?
I’m not sure about adding directories, but regarding using font files in themes, there is a built in method you could try. If you’re editing the Theme files manually, you can add the font to the theme’s /assets directory, then add an entry for it in about.json like this:
Then in the @font-face you can reference it with src: url($my-font-indentifier);
If you’re just using the Theme editor in the settings interface, I believe you can add it to the uploads section, put the identifier you want to use in the SCSS var name field, then reference it the same way in the SCSS.
Had a question about this: So, when you View Source the forums page of your (anyone’s) Discourse site, and search “font,” it shows a bunch of them. Are these fonts all loaded even though you only choose 1-2 during the setup wizard? If so, would like only the one I chose to be loaded.