Build site from multiple git branches?

Hi,

I currently use Netlify to host a few documentation sites for our company. We use Jekyll as our static site generator. Right now, we build our sites from a single git branch, which works great. We have different versions of our documentation (corresponding to different versions of our product) in discrete git branches. Example: 5.0, 5.1, 6.0, 6.1, 6.2, etc.

Can you tell me how I could set up our Jekyll build in Netlify to automatically build all of the branches we want and have them available on a single site?

Here’s our site: https://doc-site-test.netlify.app/

You can see the version drop-down menu at the top-right, but right now it doesn’t point to any other doc versions, except 6.2 (which is what I have set up in the Deploy Contexts settings. I want to know how I could build multiple branches and publish them on the site.

@mark-plummer welcome to the Netlify community!

There might be a couple ways to do this, but the way I would suggest is to have each branch exist as it’s own site. Then have a proxy rewrite for each path to the associated site. As long as the docs adhere to relative paths on each site, this option would work otherwise you might have to link out of the site for other versions.

_redirect

/6.1/*  https://doc-site-test-6-1.netlify.app/:splat  200

Also, you might be able to allow for branch deploys and proxy rewrite to those branches. This method would need to be tested, but would allow for not having to setup individual sites by branch.

Hi Tony.

Thanks so much for your response. I would love to have each branch exist as it’s own site. The docs definitely do adhere to relative paths on each site.

So, I’m not clear on how I would use proxy rewrite. If I’m on the 6.0 site and I want to have a version menu that show 6.1 and then when user clicks on it, have them taken to the 6.1 site, how would I use proxy rewrite to make that happen?

thanks,

mark.

If you are using proxy rewrites like I suggest, a user would actually never be leaving the main site. They would/should never be sent to a sub-version site url and those sites should redirect to the proxy rewrite paths (https://example.com/6.x/) . I would also suggest the main(latest) site always exist at the root, so when a user goes there, they are on the latest docs version.

I know this is going to cause some issues with your menu selections when you are on an older version, since they don’t know about future versions at the time they are branched. Unfortunately, that is something you are going to have to solve, but if you are willing to always have a latest in the menu for the main site, they can find the newer versions from there or you have to change the menus after the branch with each new version (maintenance issue).

Hope that helps.

Hi Tony,

Thanks! yeah, the proxy rewrites sounds like the way to go. I’ve never done one before. can you advise how I would set that up?

thanks again.

mark.

I gave an example _redirect file with one proxy rewrite path above :point_up_2:. I also included links to the docs on how they work.

Thanks Tony. Sorry, I missed those links in your first email. I’ll go check them out. thanks!

mark.

Hi Tony,

So I created a _redirects.txt file and put it in the publish directory for my site (built using Jekyll). I also made sure that Jeykll is configured to ignore that file (per suggestion in the Netlify docs).

However, it doesn’t seem to work. Anything I’m doing wrong?

Here’s what is in the redirects file:

/6.1/* https://docs.thoughtspot.com/:splat 200
/6.0/* https://docs.thoughtspot.com/:splat 200
/5.3/* https://docs.thoughtspot.com/:splat 200

thanks,

mark.

Hi Tony,

I used:
/6.1/* https://docs.thoughtspot.com/:splat 200
/6.0/* https://docs.thoughtspot.com/:splat 200
/5.3/* https://docs.thoughtspot.com/:splat 200
/5.2/* https://docs.thoughtspot.com/:splat 200
/5.1/* https://docs.thoughtspot.com/:splat 200

weirdly, all of the links work just fine, except for the 5.2 and 5.3 links. any thoughts on why that would be happening?

I was able to get them to work, though, by creating a netlify.toml file using following syntax:

[[redirects]]
from = “/6.2/*”
to = “https://docs.thoughtspot.com/:splat
status = 200
force = true # COMMENT: ensure that we always redirect

Hi Mark,

I’m not sure why 5.3, 5.2 would not work. If you want to force the path to always redirect even when a file exists, you need to put an ! at the end of the status 200!

So, I thought you were creating these docs into their own sites? From what I see above all those paths seem to point back to the main site. If each branch was it’s own site, I would expect to see something like:

/6.1/* https://docs-6-1.thoughtspot.com/:splat 200!
/6.0/* https://docs-6-0.thoughtspot.com/:splat 200!
/5.3/* https://docs-5-3.thoughtspot.com/:splat 200!
/5.2/* https://docs-5-2.thoughtspot.com/:splat 200!
/5.1/* https://docs-5-1.thoughtspot.com/:splat 200!

Where, every path is a different site. Only the latest version would point to docs.thoughtspot.com :grin: