简体   繁体   English

当我在 github 上部署站点时,CSS 和 JS 没有加载,netlify

[英]CSS and JS are not loading when i deploy the site on github, netlify

https://github.com/MadhavaY/RandomQuotesGenerator here is the link to the repository. https://github.com/MadhavaY/RandomQuotesGenerator这里是存储库的链接。 HTML is loading but css and js are not. HTML 正在加载,但 css 和 js 没有。 Link to the website https://madhavay.github.io/RandomQuotesGenerator/ .链接到网站https://madhavay.github.io/RandomQuotesGenerator/ I saw other answers too but i could not get where am i going wrong.我也看到了其他答案,但我不知道我哪里出错了。

You need to change the path of both files.您需要更改两个文件的路径。 As is:原样:

<script src="/All Projects/randomqotesproject/randomquotes.js"></script>

<link rel='stylesheet' type='css' media='screen' href='/All Projects/randomqotesproject/randomquotes.css'>

If you remove the path, eg:如果您删除路径,例如:

/All Projects/randomqotesproject/

It should work.它应该工作。

Hello madhava I reviewed your project and found out that you are still using your local paths to link your css and javascript您好 madhava 我查看了您的项目,发现您仍在使用本地路径来链接您的 css 和 javascript

    <link rel='stylesheet' type='css' media='screen' href='/All Projects/randomqotesproject/randomquotes.css'>

just change /All Projects/randomqotesproject/randomquotes.css to ./randomquotes.css只需将/All Projects/randomqotesproject/randomquotes.css./randomquotes.css

If changing the path doesn't work for you, you can easily add a URL to the CSS and JS instead.如果更改路径对您不起作用,您可以轻松地将 URL 添加到 CSS 和 JS。 EX: https://madhavay.github.io/RandomQuotesGenerator/randomquotes.css例如: https ://madhavay.github.io/RandomQuotesGenerator/randomquotes.css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM