Search code examples
javascriptgithub-pages

js scripts not loading on Git Hub Page


I have the following index github page but the js scripts won't load.
In my index.html, I have the following js script tag:

<script src="/js/navbar.js"></script>

However, my Github page won't load it properly.
You can view the error result via this link:

https://coddielam.github.io/JohnManganaroConstruction/


Please help me take a look. Thanks!
repo link:

https://github.com/Coddielam/JohnManganaroConstruction


Solution

  • At the moment, you are trying to access https://coddielam.github.io/js/navbar.js, which doesn't exist.

    You need to change /js/navbar.js to js/navbar.js, so that the URL resolves to https://coddielam.github.io/JohnManganaroConstruction/js/navbar.js. The extra / at the start tells the browser to look for the file at the root of the website.