bridgetown icon indicating copy to clipboard operation
bridgetown copied to clipboard

SSR Home page (index.html)

Open C-Mejlak opened this issue 2 years ago • 5 comments

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

  1. Create new bridgetown site
  2. In config/initializers.rb un-comment init :"bridgetown-routes"
  3. In the Gemfile un-comment gem "bridgetown-routes"
  4. Run bundle install

Create the route

  1. Create the routes directory src/_routes
  2. Create index.erb inside of routes
  3. Use code from items example

Current behavior

When you visit http://localhost:4000 you get a 404

image

Expected behavior

The page to be rendered

C-Mejlak avatar Mar 31 '23 09:03 C-Mejlak

@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.

jaredcwhite avatar Mar 31 '23 14:03 jaredcwhite

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 avatar Mar 31 '23 15:03 C-Mejlak

@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.html and www.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 path homeA.html or homeB.html is never visible to the users

brandonzylstra avatar Apr 01 '23 20:04 brandonzylstra

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.

C-Mejlak avatar Apr 03 '23 05:04 C-Mejlak

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. 😃

jaredcwhite avatar Apr 03 '23 05:04 jaredcwhite

Yay! I got this working in a test repo that's essentially Roda-first with minimal static anything, so just gotta backport my fix.

jaredcwhite avatar Apr 02 '24 15:04 jaredcwhite

Sounds like you have it covered :tada: Cool and thanks for the update :pray:

C-Mejlak avatar Apr 08 '24 07:04 C-Mejlak