quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.6k stars 294 forks source link

Different theme configuration for some page within a website does impact the whole website #10087

Open cderv opened 1 month ago

cderv commented 1 month ago

Reported once again for custom themed html page in website this time: https://forum.posit.co/t/directory-level-yaml-gets-applied-to-entire-quarto-website/188328/4

> quarto create project website test-subdir

Then add a subdir directory with subdir/index.qmd

{{< lipsum 1-2 >}}

and _metadata.yml

format:
  html:
    fontcolor: red

User is expecting to modify only the theme for this page.

In _quarto.yml

project:
  type: website

website:
  title: "example"
  navbar:
    left:
      - href: index.qmd
        text: Home
      - about.qmd
      - href: subdir/index.qmd
        text: Subdir

format:
  html:
    theme: cosmo
    css: styles.css
    toc: true

The results is that all Quarto theme information are merged in the same file moved in site_libs/bootstrap/bootstrap.min.css

So red will be set for $body-color https://github.com/quarto-dev/quarto-cli/blob/6b0728c9a284e68364afd736057afde29447612f/src/format/html/format-html-scss.ts#L467

and applies to the whole site.


Some notes:

mcanouil commented 1 month ago

Anyhow, I think allowing the theme to be changed across a website could be a nice/fancy enhancement but maybe not a small endeavour.

cscheid commented 1 month ago

My view is that if the behavior was intentional, then Quarto should disallow configurations that are scoped (like document and directory-level metadata) from creating settings that affect that entire project.

That happens to be a hard thing for Quarto to detect given the way metadata is stored and processed.

So this bug would be fixed in either of two ways, (both hard to do for different reasons):