Hi,
you may have found an undesired behavior or a bug. Let's explain what is going on.
In HTML document, you show that you can separate the yaml metadata definition in several blocks: it is a nice pandoc feature. If two metadata are the same, the first one is used and metadata from the document are erase by other provided as arguments.
However, when Rmarkdown does not see a title in the yaml header, for a avoiding pandoc2 warning, it will add a metadata pagetitle
as argument in pandoc call, by using the --metadata
flag, that is prioritary on document metadata. This is set to the document intermediary input name : *.utf8.md
.
As no title was provided in your yaml header in html example, a pagetitle
has been set and if you search for utf8.md
in html source code, you should find it.
(this is a first undesired behaviour for me)
So why do you have the correct title in html anyway ?
This is because html document template is using two variables : pagetitle
and title
. In your html example, both are set, and the title is used to set the h1
title as you can find in the template.
Let's note that when a title is provided in the yaml header, no pagetitle
is added in pandoc call, and if no pagetile is set explicitely, it is set by pandoc to the title provided.
We would expect for flexdashboard to be the same. And it fact, it is. However, the flexdashaboad pandoc template does not use a title
variable., only pagetitle
.
This is why when you set title
in the Rmd, it does not work because pagetitle
provided in --metadata
flag superseed.
I think flexdashboard should use title
for the nav bar: this is a second undesired behavior
For now, I don't have a solution for flexdashboard unless you modified the title at loading with javascript the navbar title.
Something like this
---
output:
flexdashboard::flex_dashboard
---
```{r setup, include=FALSE}
library(flexdashboard)
my_title <- "I am the title"
```
<script>
document.querySelector(".navbar-header > span.navbar-brand").innerHTML = "`r my_title`";
</script>
Test R Markdown flexdashboard
Thanks for the strange behavior report. Some issues should be raised in several repos.