-
Here you can see the Hydrogen version, font files in the public directory, and the font face CSS declarations: The fonts are properly loading on localhost: However, when deployed to Oxygen, the font face URLs are relative to If we look at another file in that public directory in that build, the favicon, you can see a URL like this I can't find Hydrogen v2 tutorials, but this approach is in-line with the v1 tutorial and I don't see any mention of fonts in the migration guides. Is this a Hydrogen bug where the Oxygen build should use a generated asset base URL for the font face URL paths? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
This is a total hack, but for now, I replace the relative font face URLs with absolute URLs from one of my Oxygen builds.
|
Beta Was this translation helpful? Give feedback.
-
I had the same issue. Add the fonts directory inside of the app directory instead of the public. Then update your font URLs to be relative, e.g. |
Beta Was this translation helpful? Give feedback.
-
As Steve mentioned, you can place your fonts in the This is something we recently discussed internally. We'll try to improve this somehow. |
Beta Was this translation helpful? Give feedback.
-
@frandiox @stevepsharpe thank you! |
Beta Was this translation helpful? Give feedback.
-
I have the same problem but with images. background-image: url('/beauty-image.png'); // works localhost, file is located in public/ background-image: url('./images/beauty-image.png'); // doesn't work, even if if i move the image to app/styles/images/beauty-image.ong |
Beta Was this translation helpful? Give feedback.
As Steve mentioned, you can place your fonts in the
app
directory and use a relative path. That's what we are doing in our demo-store: https://github.com/Shopify/hydrogen/blob/main/templates/demo-store/app/styles/custom-font.css#L5This is something we recently discussed internally. We'll try to improve this somehow.