Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
GitHub Pages - including files from same repo

So, I have a repo on GitHub which is displaying a website via GitHub Pages. The publishing source is the /docs/ subfolder on the master branch (and this is the only branch). I have some other JavaScript files in a /src/ subfolder. So essentially, the project structure is something like:

/
 docs/
      index.html
 src/
     Main.js
     ... (other .js files) ...
 README.md
 ...

Now, I want /docs/index.html to be able to load and use /src/Main.js. On my local machine, this is easy enough - I can just reference it as

../src/Main.js

inside my /docs/index.html file.

However, when I try to view the live project on GitHub, there are problems. The live version of /docs/index.html file is now located at

https://(my-username).github.io/(my-repo-name)/

Therefore, it looks for /src/Main.js at

https://(my-username).github.io/src/Main.js

which returns a 404.

Actually, I don't even know where I can find the /src/Main.js file, as

https://(my-username).github.io/(my-repo-name)/src/Main.js

also returns a 404.

So, how can I load the /src/Main.js file from my /docs/index.html file? Ideally, I'd like a solution that will work both on my local machine, and on the live version.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found the solution. It seems that GitHub Pages can only find files that are in the "publishing source". Therefore, if you have the publishing source set to /docs/, it won't be able to access files outside the /docs/ folder.

So, the solution is to set the publishing source to root /, move index.html to root, and then you can access all subdirectories of the root (including the /src/ subfolder).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!