title: Shiny: How to change the page/window title in Shiny?
body: <p>There are numerous posts regarding changing titles of other pieces of Shiny apps, e.g.:<br />
  <a href="https://stackoverflow.com/questions/63060893/change-the-title-by-pressing-a-shiny-button-shiny-r">Change the title by pressing a shiny button Shiny R</a><br />
  <a href="https://stackoverflow.com/questions/51688463/shiny-page-title-and-image">Shiny page title and image</a><br />
  <a href="https://stackoverflow.com/questions/35549235/shiny-app-how-to-dynamically-change-box-title-in-server-r">Shiny App: How to dynamically change box title in server.R?</a></p>
  <p>My question is related, but not answered by any of these. I would like to make the <code>&lt;head&gt;&lt;title&gt;...&lt;/title&gt;&lt;/head&gt;</code> tag reactive, or at least controllable from within an <code>observeEvent</code> in <code>server.R</code>.</p>
  <p>The following does not work, since <code>ui</code> can't find <code>theTitle</code>, but is the kind of approach I'd hope is possible:</p>
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
     title = theTitle(),
     textInput(&quot;pageTitle&quot;, &quot;Enter text:&quot;)
  )
  
  server &lt;- function(input, output, session) {
      theTitle &lt;- reactiveVal()
      
      observeEvent( input$pageTitle, {
        if(is.null(input$pageTitle)) {
          theTitle(&quot;No title yet.&quot;)
        } else {
          theTitle(input$pageTitle)
        }
      })
  }
  </code></pre>
  <p>I've tried making <code>output$theTitle &lt;- renderText({...})</code> with the <code>if..else</code> logic in that <code>observeEvent</code>, and then setting <code>title = textOutput(&quot;theTitle&quot;)</code> in <code>ui</code>'s <code>fluidPage</code>, but that generates <code>&lt;div ...&gt;</code> as the title text, or <code>&lt;span ...&gt;</code> if we pass <code>inline=True</code> to <code>renderText</code>.</p>
  <p>In case this clarifies what I'm looking for, the answer would make something equivalent to the <em>literal</em> (replacing string variables with that string) <code>ui</code> generated by</p>
  <pre><code>ui &lt;- fluidPage(
      title = &quot;No title yet.&quot;,
      ....
  )
  </code></pre>
  <p>before the user has entered any text in the box; if they have entered &quot;Shiny is great!&quot; into <code>input$pageTitle</code>'s box, then we would get the literal</p>
  <pre><code>ui &lt;- fluidPage(
      title = &quot;Shiny is great!&quot;,
      ....
  )
  </code></pre>