Reputation: 31
I am trying to create a parametrised Quarto book where the title of the book, set in _quarto.yml, changes depending on a parameter "name", but I can't get this to work. I use r params$name
in the title, but it always prints out the in line code into the title rather than the output.
Here is my _quarto.yml code below:
project:
type: book
execute-dir: project
book:
title: "Test title for `r params$name`"
chapters:
- index.qmd
- contact_us.qmd
format:
html:
theme: cosmo
fontsize: 16px
mainfont: Arial
execute:
echo: false
warning: false
editor: source
And the index.qmd where parameters are set:
---
params:
name: "Test"
engine: knitr
---
## Introduction {.unnumbered}
This book is about `r params$name`.
So r params$name
prints out the output when used in the qmd file, but not the YAML. It looks like parameters must be set in the YAML of each qmd file, rather than in the Quarto YAML script (post). Could this be the cause of the issue?
Any help would be greatly appreciated, thanks!
Upvotes: 3
Views: 1311
Reputation: 321
Meta parameters worked for me:
"title: "Reportfor {{< meta params.WhoFName >}} {{< meta params.WhoLName >}}."
Upvotes: 2