probberechts / hexo-theme-cactus

:cactus: A responsive, clean and simple theme for Hexo.
https://probberechts.github.io/hexo-theme-cactus/
MIT License
3.18k stars 783 forks source link

Hexo 6.0.0 issue with css #296

Closed h0ek closed 1 year ago

h0ek commented 2 years ago

In my test environment I updated Hexo to latest 6.0.0 version and only main page looks good, rest looks broken, like css style would not load. Could you please check if you have same problem or is it something on my side. I tested in on two different systems and it seems to be broken, when I downgrade Hexo back to version 5 it works good.

Refused to apply style from 'http://localhost:4000/2022/01/07/test-post/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Failed to load resource: the server responded with a status of 404 (Not Found) main.js

Refused to apply style from 'http://localhost:4000/categories/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

h0ek commented 2 years ago

I temporary fixed the problem with style changing head.ejs line from <%- css('css/style) %> to <%- css('css/style', {relative: false}) %>

but I see this is probably global issue because it is doing the same for js files. it tries to load /2021/12/21/js/main.js rather than /js/main.js

so in scripts.ejs I did the same <%- js('js/main', {relative: false}) %>

maybe above investigation will help you fix theme and make compatible with Hexo version 6.0.0.

probberechts commented 2 years ago

Thanks for reporting this. I think this was a bug in hexo-util@2.5.0. I've now tested it with a clean setup in hexo@6.1.0 and didn't encounter any issues. Could you check if upgrading works?

h0ek commented 2 years ago

I updated Hexo to version 6.1.0 in my test environment, roll back changes above and it doesn't work. Same problem with no css loaded for post content. I will do another check, but I need first update theme to latest version as I can see you made some changes yesterday. Just to be sure that I do not miss anything.

kamasylvia commented 1 year ago

Same problem, hexo 6.3.0

h0ek commented 1 year ago

Hmm, I tested it again with hexo server locally and it works, but on my server hosted on nginx it doesn't. I disabled almost everything in nginx.conf and in site conf, but still nothing. Now I know it is probably related to some web server configuration and not hexo itself. Anyone is hosting hexo with nginx? (but not as a proxy to hexo server but as a nginx server) and could share with me working conf?

As main page load correctly, and all pages form menu too, but each post got issue with js and css.

it is definied in style section:

<!-- styles -->
<link rel="stylesheet" href="../css/style.css">

it works on home page, and when you enter for example any post to path like /2023/05/22/title/ and from developer tools I see GET https://website.com/2023/05/22/css/style.css net::ERR_ABORTED 404

Looks like handling styles and js files are not correctly executed by theme. I tried to workaround this using some nginx redirection and relative path, but found nothing, and in the past it works without any server conf magic :)

h0ek commented 1 year ago

Kill me... I had to change relative_link to false from true in my hexo config. Sorry for the mess.