Open puzant opened 4 years ago
It's probably because your website is not served from the baseURL
in your config.toml.
see https://discourse.gohugo.io/t/theme-not-working-on-netlify/11849
I have a baseUrl
set in my config.toml
but still no luck they only way was this to work was to build the files and go change the public/index.html
by removing the baseURL
from my the CSS
& JS
imports there
What happens when you refresh your browser after seeing the theme is not displayed? I have had the same experience described above. I haven't done the verification on this yet, but I suspect it is due to the site rendering before the css is fully downloaded - which is why it would work on reload and work on a local server but not when hosted remotely and on your first visit to the site. You can also click on one of your links to another page and you may find that the theme is being rendered, as I do.
it stays as it is after refreshing, even if I click on some of the links the styles still do not show, however one thing I noticed that when running the hugo
command and checking the final generated index.html
and the other files, there's was crossorigin="anonymous"
on each of my imports, on the styles & JS imports, once I removed them the styles were back on display and with JS functionality
I encountered some problems similar to this and have worked my way through one of them. I thought I would document it here in case anyone encounters this in the future.
I had a similar (but I believe different) problem than the OP in terms of rendering not working. My home page was not rendering properly but when I navigated back to the home page via links in my page, everything was fine. Here is what I believe the problem was. When I ran "hugo server," Hugo bound to http://localhost:1313. In my browser, however, I was typing http://127.0.0.1:1313. Although localhost is equivalent DNS-wise to 127.0.0.1, they are different URLs but with cross-origin=anonymous, the CORS same-origin attribute was being set (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin). When I browsed to http://localhost:1313, everything was fine. Lesson learned!
Now I need to work on the next problem - but I think it's related.
I thought I'd post an update on this. The crossorigin matter was at the root of my other error as well. My hosting provider allows me to have both the www subdomain as well as the "naked" domain pointing at the same web site (as in www.example.com and example.com). My Hugo baseURL is defined as www.example.com. When I browsed to https://example.com, the CSS did not render because of the crossorigin configuration while going to www.example.com worked fine. I was able to configure a 301 Redirect on my hosting provider from example.com to www.example.com to solve the problem.
I thought I'd post an update on this. The crossorigin matter was at the root of my other error as well. My hosting provider allows me to have both the www subdomain as well as the "naked" domain pointing at the same web site (as in www.example.com and example.com). My Hugo baseURL is defined as www.example.com. When I browsed to https://example.com, the CSS did not render because of the crossorigin configuration while going to www.example.com worked fine. I was able to configure a 301 Redirect on my hosting provider from example.com to www.example.com to solve the problem.
Choose "www" or "non-www", then you need a dns record to redirect one to the other And probably close the issue 👍
I've added the Hermit theme to use in my Hugo website, and started developing & adding content, evrything was working perfect in development mode(when I was running the hugo server
hugo server -D
) but when runhugo
command to build & deploy my site, only the ugly HTML was showing on my websitelike this
but when running the server the website looks great
Config.toml
& the pages paths are always redirecting to 404 not found
I'm really frustrated, I've tried everything & read the docs three times but still no fix whatsoever, any help would be appreciated