Can I publish multiple branches of a repository on GitHub Pages?

I have already published the master branch of my repo on Github Pages. Can I somehow publish another branch of the same repository so the the url is something like: username.github.io/repositoryname/branch ? Or will I have to create another repository instead of a branch to publish it?

12 Likes

Hi @ankitasood

Can I somehow publish another branch of the same repository so the the url is something like: username.github.io/repositoryname/branch ? Or will I have to create another repository instead of a branch to publish it?

GitHub Pages only lets you configure one publishing source for a particular repository. So in this particular case, you’ll need to create a new repository and add the content you’d like to publish with GitHub Pages to that newly created repository.

Does that answer your question? Please let me know if I misunderstood you or you have additional questions. 

5 Likes

Hi there!

It’s a pity it works that way. In my case, I am maintaining an open source project hosted on GitHub. The project has several major versions (few of them still supported and maintained separately on different branches of the repo). It would be very nice if I could have the documentation of each of those versions/branches published separately.

Best,

Thomas

34 Likes

Exactly, also it’s doesn’t help when working on documentation because you can’t preview what will be build on the github doc site until it’s merged into master…

What I’d prefer, is to automatically build one doc site for each branch that have a docs/ folder, and use either subdomains or a different domain for docs generated from branches that aren’t the default branch (usually “master”)

Example:

https://unlyed.github.io/next-right-now/ (“master” branch)

https://unlyed-docs.github.io/next-right-now/  (“docs” branch)

https://docs.unlyed.github.io/next-right-now/ (“docs” branch)

I think the latest looks the cleanest.

It could be done either automatically for all branches, or through a pattern (v*, for all v1, v2 branches and such) or enabled branch by branch.  Pattern allows for automation and would reduce maintainance/configuration.

This would be much more usable.

2 Likes

I’m using github pages for my master branch but netlify for the dev branch, as they allow hosting for seperate branches.