3

I have a repository in github which will house all of my web development assignments in separate sub-folders like :

VishnuVelukutty/ CourseraWebdevAssignment (master)/ module2-assignment (subfolder)

So the master branch has gh-pages and I want to add the gh-page to all sub-folders (Assignment1,2,3 .....) independently so that they work independently when the specific module-link is opened

Is it possible to apply gh-pages to a subfolder ? or do I have create independent repo for each module ?

I have not initiated .gitignore, static site, readme nor theme and reffered to this post by cobyism and chrisjacob but i didn't get it working

Here is my github account to see if there any errors in setting up

For reference of the images here is the git link

1 Answers1

1

First, make sure to create a gh-pages branch, add at least one commit in it and push it to your GitHub repository.

Then, yes, you can add that gh-pages branch content as a subfolder of your current repository, in the master branch, using git submodule.
(unless, as explained here, you chose the master branch itself as source for GitHub Pages)

git checkout master
git submodule add -b gh-pages -- /remote/url/of/your/own/repo gh-pages
git commit -m "Add gh-pages branch as submodule"
git push

You will have a gh-pages subfolder, that you can update at any time with:

git submodule update --remote
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I used that technique many times before: https://stackoverflow.com/a/40967706/6309 – VonC Jul 18 '20 at 12:59
  • i followed the steps you mentioned but i am still unable to get it right (so if it possible for you to look into my github account above and correct me it would be really helpful) – Vishnu Ezhuthachan Jul 20 '20 at 07:48
  • @VishnuEzhuthachan Your repo looks good. You just need an `index.html` in your gh-pages branch/folder for anything to be visible in your GitHub page. – VonC Jul 20 '20 at 10:37
  • But the index file is inside module2-assignment and that doesn't display – Vishnu Ezhuthachan Jul 20 '20 at 15:50
  • @VishnuEzhuthachan I don't see that file (for instance in https://github.com/VishnuVelukutty/CourseraWebdevAssignment) Do you have an URL? – VonC Jul 20 '20 at 16:16
  • https://github.com/VishnuVelukutty/CourseraWebdevAssignment/tree/master/module2-assignment – Vishnu Ezhuthachan Jul 21 '20 at 11:42
  • @VishnuEzhuthachan But that is not the gh-pages branch you mention in your question, it is the master branch. Did you configure your master branch to host pages? (as in https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#choosing-a-publishing-source) – VonC Jul 21 '20 at 12:07
  • I don't understand how to do this.. can we create a separate github site for each subfolder ? But under the settings option of the repo you can only select a single folder right? @VonC – Akhila Mar 15 '21 at 13:20