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?
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.
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.
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.
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?
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).
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?
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: