I’m having troubles with setting up a website built in R with Hugo, hosted on GitHub and Netlify.
It seems like Netlify isn’t reading the css file properly and my website doesn’t currently have a theme. In addition, it looks like the links are broken. Perhaps something related with the site map, although I’m not certain.
I’m a newbie in Netlify and I’ve already spent a lot of time trying to figure out why these two aren’t working. Could anyone help me with setting up properly the website?
If the CSS file is where it’s supposed to be and your pages have the correct links to that file, but the file is not being delivered properly, that is indeed a problem.
If, on the other hand, the CSS file is missing and/or the links to the CSS file are not correct, that’s something you’ll have to correct.
However, without more information it’s very difficult for others to help you.
@simonagradinaru The only problem I’m seeing is that your favicon is not present (or properly linked). Everything else looks fine. Are you perhaps seeing the results of browser, computer, ISP, or VPN caching?
@gregraven I figured out the css issue in the meantime. Apparently, I wasn’t building my site so running hugo serve was all I needed to do.
Could you give me a hand with the favicon you’ve mentioned?
Thanks!
@simonagradinaru I don’t know how you include it using Hugo, but once you have an image you want, this free online generator will create all the icons and link code for you.
Fantastic! Thanks a lot @gregraven for the reference, I’ll look into it.
In the meantime, my website is almost ready to launch (really excited about it!), but I cannot figure out why my posts aren’t reading the css file. Any idea?
@gregraven That’s really weird, but somehow cheering up. I’ve tried clearing the browser, the caches, accessing the website through multiple devices on private browsers. Unfortunately, nothing works. Everywhere I’m opening the website (except locally), I still encounter the red box elements.
Hi @simeon9696! I think author and date are Common Font Matter variables in Hugo. My judgement was that they’re predefined and I don’t have to define them manually in a different script.
Yeah, something is definitely cutting it out, but I’m still having troubles in understanding why this happens and how to solve it.
@simeon9696 That’s exactly what I see as well, although everything seems to work fine locally. @gregraven Any ideas for how to escape the cache trap? I have tried on multiple devices, private / incognito, serving the website with hugo server --noHTTPCache, but the output is the same.
@simonagradinaru good news! I had some time to look into your problem.
The styling wasn’t being applied on the posts but it was there on the homepage so I checked the Network tab in developer tools and sure enough the homepage was pulling in main.css but the posts weren’t. That’s what led me to believe it was your build process.
It seems that in your .gitignore file you excluded the public directory. From Hugo’s documentation:
Running hugodoes not remove generated files before building. This means that you should delete your public/ directory (or the publish directory you specified via flag or configuration file) before running the hugo command. If you do not remove these files, you run the risk of the wrong files (e.g., drafts or future posts) being left in the generated site.
So I think what happened is that it probably wasn’t being overwritten and netlify kept deploying the old folder? In any event here’s how you can fix it
1.) Delete the public folder from your local machine
2.) Add public/ to your .gitignore
3.) Commit the changes to your repo and push it to github
4.) Netlify should automatically trigger the rebuild so just wait.
Thank you very much, @simeon9696! That worked flawlessly! I have no idea how I missed it - either ignorance or I must have been in a hurry.
In the meantime, I moved my website here and it’s working perfectly. Thanks for saving my day!