How do you handle the document <title>?

Does anyone know how to gracefully handle updating the document’s when a partial page is returned as part of an advance action? In other words, we’re returning a response, via data-turbo-action="advance", but without a layout.

We’d rather keep <title> co-located with the content being returned, rather than updating it via Stimulus. Any suggestions?

1 Like

I’m searching for a solution to this as well.

One option might be to use turbo-stream, which could be nested inside

  <title id="page-title">My Title</title>
  <turbo-frame data-turbo-action="advance" ...>
<turbo-frame ...>
  <turbo-stream action="update" target="page-title">
    <template>New Title</template>

1 Like

That’s creative. I’ll give that a try.

You could also write a stimulus controller, to update the title on connect, but for this scenario I prefer this approach if it works.