-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS styles inside static folder do not load when there is a trailing slash on route #11628
Comments
Try importing the custom css file directly into custom_page.js instead of using the SEO component to add a link. The SEO component may be adding the link to the custom.css before the link to your regular CSS causing it to be overwritten.
|
This worked for me and can use it as a solution for now but I am sure something can be done to make my earlier option work but that's for better coders than myself |
@itrevex PRs are more than helpful if you could share where things were confusing! Generally - this is less a Gatsby issue and more a modern build process/expectation enabled with the rise of Webpack. This works the same way as tools like create-react-app! That being said--sorry for the confusion here, and glad we have it ironed out. Closing this out, but please feel free to continue discussion if we can help further. Thanks! |
Description
I picked up a template and converted to a react a component. I then decided to pass its styles through
link
tag in header of the page using react-helmet.The styles work fine when I route the the page without no trailing slash but on routing to the pages with a trailing slash, the styles do not work. I have searched around but looks like the issue is unique to me
Steps to reproduce
static
foldercustom.css
file with some styles that will be referenced inside custom page<Link to "/custom_page" >custom page</Link>
inside pages/index.js file<Link to='/custom_page/'>Custom page</Link>
Clear steps describing how to reproduce the issue. Please please please link to a demo project if possible, this makes your issue much easier to diagnose (seriously).
What should happen?
Custom css should load in page when page is routed to with trailing slash
What happened.
Custom css does not load when page is routed to with trailing slash however, the link to the custom css file is available in the header tag
Environment
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
Binaries:
Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
npmPackages:
gatsby: ^2.0.117 => 2.0.117
gatsby-image: ^2.0.29 => 2.0.29
gatsby-plugin-manifest: ^2.0.17 => 2.0.17
gatsby-plugin-offline: ^2.0.23 => 2.0.23
gatsby-plugin-react-helmet: ^3.0.6 => 3.0.6
gatsby-plugin-remove-trailing-slashes: ^2.0.7 => 2.0.7
gatsby-plugin-sharp: ^2.0.20 => 2.0.20
gatsby-source-filesystem: ^2.0.20 => 2.0.20
gatsby-transformer-sharp: ^2.1.13 => 2.1.13
The text was updated successfully, but these errors were encountered: