SSR Home page (index.html)
Server-side rendering of the homepage does not seem possible? I've followed the docs and tried the file-based routing. The items example works as expected.
Bridgetown Version:
bridgetown 1.2.0 "Bonny Slope"
To Reproduce
Create a new site and enable bridgetown-routes
- Create new bridgetown site
- In
config/initializers.rbun-commentinit :"bridgetown-routes" - In the
Gemfileun-commentgem "bridgetown-routes" - Run
bundle install
Create the route
- Create the routes directory
src/_routes - Create
index.erbinside of routes - Use code from items example
Current behavior
When you visit http://localhost:4000 you get a 404

Expected behavior
The page to be rendered
@C-Mejlak I don't expect we'll ever support this feature. The point of building a hybrid website with both static routes and dynamic routes is that you first architect as many routes statically as possible (and perhaps "punch holes" in a few places here and there using techniques like Turbo Frames or Streams, etc.), and for pages which simply don't make sense in a statically-generated context, you can then add those as dynamic routes. Making the homepage a dynamic route would defeat the purpose of using a static site generator.
If there's some specific caveat to this I'm not foreseeing, please let me know.
Hey @jaredcwhite I'm really excited by ability to SSR pages for many reasons. It does open the doors to endless possibilities. One of the maybe not so obvious reasons is running A/B tests for conversion rate optimization.
Consider for example testing between two headings above the fold. While you can achieve this client side, you would need to block the rendering until you choose which heading to render. Not ideal.
With SSR this would become trivial.
I don't want to lose all the benefits that come with static generation, but if I can have the cake and eat it too... :)
@C-Mejlak could you do something like this for an A/B test?
- create static routes for all the versions of the home page that you want to test, so you have for example
www.example.com/homeA.htmlandwww.example/homeB.html - have the load balancer choose (randomly, or using whatever criteria you want) between A and B when it receives a request for
www.example.com/, but do so invisibly so that the pathhomeA.htmlorhomeB.htmlis never visible to the users
Hey @brandondrew, technically it is possible. Netlify also offers something similar with branch-based testing.
For some context when running experiments sometimes you'll have six variations, and on rare occasions even more, with some of the experiments running for weeks. Now imagine you need to update a link - you'll have to replace it on six pages/branches. So while doable, it does introduce friction.
I guess the question is: should it be possible to SSR any other page except for the homepage? And why?
If it's because technically it's challenging to do and/or requires substantial effort, then I agree. After all this might not be relevant to most Bridgetown users.
If on the other hand it's because ideally we don't want Bridgetown users doing that; what I'm saying; there might be instances, where doing this temporarily is the easiest and cleanest way.
While I'll maintain that the ideal "Bridgetown architecture" starts with static pages and augments with dynamic routes, it seems like keeping this technical hurdle is more a matter of "well that's just how it works" rather than an inherent limitation for all time. Thus you have convinced me this should be an option. 😃
Yay! I got this working in a test repo that's essentially Roda-first with minimal static anything, so just gotta backport my fix.
Sounds like you have it covered :tada: Cool and thanks for the update :pray: