Replacing elements in template root not working although advised

Reading the chapter Performance and Debugging about layouts, we’re invited to use templates and then append elements to the root of the main.

However replacing an element of main will not update the layout, no redrawing is happening.

The work around is to append a Column as root, then modifying this Column’s elements.

e.g. doing something like:

dashboard = pn.template.BootstrapTemplate(
    title='My Site', 
    header_background='#73a917')
dashboard.main.append("# Title")
dashboard.main.append(layout1)

and then later dashboard.main[1]=layout2 will not update the second element.

We need to do

dashboard = pn.template.BootstrapTemplate(
    title='My Site', 
    header_background='#73a917')
dashboard.main.append("# Title")
dashboard.main.append(pn.Column(layout1))

and then dashboard.main[1][0]=layout2

I believe both this issue and work around have been mentioned in the past. I am hesitating opening an issue as I can see you’re working on panel 1 compatible with Bokeh 3, some perhaps some of these issues will disappear.

What do you advise?
Or other question about the internals of panel: how can I trigger the redrawing of a template’s main element?

I believe this answer here directs me to the fact we need to modify a “container” rather than an element at root level.