Github pages JavaScript problem

When my site is published with GitHub pages, my JavaScript file is not being used.

My JavaScript file is actually located at

Instead the following is being referenced

1 Like

Hey! Have you tried replicating this locally with Jekyll? Can you link a GitHub repo with the code?

I’ve also attached a DOM screenshot. It looks like code is being injected somehow into the DOM. A different JavaScript link is being inserted instead of my link to my main.js file. Very strange.

When I open my GitHub pages site, the page loads fine but obviously the JavaScript is not working

1 Like

Here is a quick test, try moving all of your JS into a script tag rather than a separate JS file.

It looks like you’re using your <script> tag to both point to an external file and contain inline javascript. You can’t use both at the same time so you’ll need to choose one or the other. This is likely what’s causing your javascript to appear inline in the page.

I’d recommend you remove the inline javascript from your HTML file and change your script tag to point to your main.js file:

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