I’m trying to resolve an issue with the Indigo theme as deployed to the themes gallery. This is part of a deeper audit. Right now, the gallery’s demo site does not load its custom fonts, which are bundled in the /static/fonts folder.
I understand why it doesn’t work — in /static/css/fonts.css, the @font-face declarations look like this:
That works great when deploying to a root domain, as you can see here. But if it’s in a subfolder, the src: url('/fonts/fontname.ttf'); points to the domain root, which is (of course) wrong.
As I said, I understand what the problem is, but I’m struggling to find an elegant solution.
In an HTML file, I can get an asset from the theme’s /static folder with something like:
But that doesn’t work in CSS files, for whatever reason. I could use inline CSS in an HTML partial, but that feels like a very hack-y workaround. How do you all load assets from the /static folder in your CSS files?
Partial URLs are interpreted relative to the source of the style sheet, not relative to the document:
So I think if you do
src: url('./fonts/charter_regular-webfont.eot');
(i.e. starting urls with a dot) then the browswer will load the font files from a relative directory, rather than working a directory based on web root.