r-markdownquartoreveal.js

In a Quarto Revealjs presentation, how can I exclude slides based on parameters set in YAML?


I am preparing slides for a course in Quarto using Revealjs.

How can I render two different versions of the presentation? One for the students (including tasks) and one for the presenter (including solution slides). I tried to use the following in the YAML:

params:
  version: "student" # or "presenter"

and then conditionally render slides using

::: {.content-visible when-params.version=="presenter"}

## Solution to Task 2

2 + 2 = 4 

:::

But independent of what is set as version, the solutions are shown. What can I do alternatively?


Solution

  • Following the docs on conditional content you can achieve your desired result by matching on boolean meta data like so:

    ---
    title: "Untitled"
    format: revealjs
    version: 
      presenter: false
    ---
    
    ## Task 2
    
    ::: {.content-visible when-meta="version.presenter"}
    
    ## Solution to Task 2
    
    2 + 2 = 4 
    
    :::
    

    enter image description here

    And when set to true:

    enter image description here