I have a repository called, let's say, odds-and-ends. Within that repo is the folder, js-projects, and then another folder within that is quick-js-app. quick-js-app contains all the ingredients of a basic web page, including an index.html, CSS and JS file, etc.

It's quite easy to publish the subdirectory quick-js-app to GitHub pages (for example, this gist by cobyism tells how to do so).

But, is it possible to publish quick-js-app so that it retains the file path, i.e., it would be located at http://myusername.github.io/odds-and-ends/js-projects/quick-js-app?

(Note, someone asks about this here within the gist thread from above - Gulp is suggested as a solution, but I didn't have any luck with it.)

Does anyone have a suggestion for me?

  • No one has a suggestion? :( Perhaps it's simply not possible?
    – aroaro
    Feb 16, 2017 at 5:48

1 Answer 1


If branch gh-pages already exists, delete it.

git branch -D gh-pages

Create a new branch gh-pages without any content.

git checkout --orphan gh-pages

Remove all initially cached files from the index.

git rm -r --cached .

Add, commit, and push js-projects/quick-js-app. If gh-pages is already on github, you need to force the push using -f. Be aware that this deletes all already existing content in different directories like js-projects/complex-js-app.

git add js-projects/quick-js-app
git commit -m "Publish"
git push [-f] origin gh-pages
  • Thanks so much for this, I really appreciate it! It works really well and I am going to experiment with publishing several subdirectories too.
    – aroaro
    Feb 22, 2017 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.