Open cderv opened 2 weeks ago
the title set in metadata is not used in the header block or HTML header (nor emitted correctly via {{< meta title >}} in the body) when a title is set in the document header. When there is no title entry in the YAML header, the title set in metadata is used and does appear in the body.
I believe this is related to the order of YAML fields, and what Quarto R package is doing.
As we document in https://quarto-dev.github.io/quarto-r/reference/quarto_render.html quarto_render
has two arguments:
metadata
which is a list that will be converted to YAML file and passed to ...metadata-file
used as --metadata-file
option in quarto --metadata-file
will have lower precedence on YAML header content. This is expected by Pandoc (https://pandoc.org/MANUAL.html#option--metadata-file) and we document it as such too in our Reference pages
So the behavior you see is expected, but really Quarto R package does not make that clear. 🤔
metadata=
is currently a way to provide a R list of object to be converted internally to YAML, and not really passed content to -M
option - because R objects can't be directly. -M
or --metadata
only allows boolean or string really.
Currently you need to do the following
quarto::quarto_render("template.qmd", metadata = list(author = "Whoever"), quarto_args = c("--metadata", "title=Hahaha"))
I'll see how I can make this easier in the R package function 🤔
Could be related to quarto-dev/quarto-cli#8987
when I try to set title via metadata like so:
the title set in metadata is not used in the header block or HTML header (nor emitted correctly via
{{< meta title >}}
in the body) when a title is set in the document header. When there is no title entry in the YAML header, the title set in metadata is used and does appear in the body.Setting e.g. the author via metadata works correctly.
Originally posted by @petrbouchal in https://github.com/quarto-dev/quarto-cli/issues/8987#issuecomment-2116261659