Pete900
Pete900

Reputation: 2176

Rmarkdown tab name in browser

I'm struggling with what to Google to start solving this one. It might be a Windows question and not an R question but I could do with some help.

I am using rmarkdown::render to generate html reports. I have a master.Rmd which calls some child_docs. I use the argument output_file = to name the html document. This works fine and I can successfully generate documents called my_report1.html. When I open the html document in my browser (both Chrome and FireFox) the browser tab is labelled as master.utf8.md:

Chrome tab label

In the past the tab label used to be my_report1.html. I want to fix this because I regularly have multiple reports open and navigating between the tabs to find which report I want is now painful.

Any thoughts on what to check?

The YAML:

---
output: 
  html_document:
    toc: true
    toc_float: true
params:
  lot: 1
editor_options: 
  chunk_output_type: console
---

Chunk setup:

```{r setup, include=FALSE}
## GLobal chunk options
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
```

Update: I think this is to do with the YAML title:. I'm going to open a new question with a better example.

Upvotes: 4

Views: 1136

Answers (1)

Pete900
Pete900

Reputation: 2176

I managed to cobble together a work around for this. The tab name in a browser comes from the title declared in the YAML even if you supply a file name to output_file in rmarkdown::render. I wanted to set my title dynamically and this can be done with using the methods described here, example:

---
output: html_document
--- 

```{r}
title_var <- "Sample Title"
```    
---
title: `r title_var`
---

However, I needed an extra work around to suppress the title because I didn't actually want it to make a title. This can be done by using the following css (top of doc or separate file):

<style>
  .title{
    display: none;
  }
</style>

Upvotes: 2

Related Questions