Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting title via metadata in quarto_render does not work #181

Open
cderv opened this issue May 17, 2024 · 3 comments
Open

Setting title via metadata in quarto_render does not work #181

cderv opened this issue May 17, 2024 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented May 17, 2024

Could be related to quarto-dev/quarto-cli#8987

when I try to set title via metadata like so:

quarto::quarto_render("template.qmd", metadata = list(title = "Hahaha", author = "Whoever"))

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 quarto-dev/quarto-cli#8987 (comment)

@cderv
Copy link
Collaborator Author

cderv commented May 17, 2024

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
image

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 🤔

@cderv cderv added the enhancement New feature or request label May 17, 2024
@cderv cderv added this to the next version milestone May 17, 2024
@durraniu
Copy link

metadata = list(author = "Whoever") did not work for me on quarto version 1.5.57 and {quarto} version 1.4.4. I also tried it in quarto_args similar to how title is provided but that caused an error in quarto cli.

@cderv
Copy link
Collaborator Author

cderv commented Sep 11, 2024

@durraniu I can't reproduce. It works for me in a simple document.
Please to open a new issue with a reproducible example. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants