The expression in the YAML header must be formatted using !expr (see note at the bottom).
---
title: "Untitled"
output:
html_document:
css: !expr system.file("shinydashboard.css" , package = "shinydashboard")
---
## Header
```{r meta}
rmarkdown::metadata
```
This produces the following output where you can clearly see the CSS loaded correctly.
![enter image description here]()
To understand what is happening during the render, it is valuable to look at the pandoc command being run. For your multi-file update, we can run static and dynamic for a comparison.
---
title: "Untitled"
output:
html_document:
css: [ 'www/file1.css', 'www/file2.css' ]
---
# /usr/lib/rstudio-server/bin/pandoc/pandoc +RTS -K512m -RTS so.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output so.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/share/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --css www/file1.css --css www/file2.css --variable 'theme:bootstrap' --include-in-header /tmp/RtmpRdKgYW/rmarkdown-str3eef4edabf99.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
Importantly, you will see --css www/file1.css --css www/file2.css, and the file renders correctly with both CSS files included.
---
title: "Untitled"
output:
html_document:
css: !expr x <- list.files(path = "www", pattern = "*.css", full.names = T); x <- paste(x, collapse = "\', \'"); z <- paste0("[ \'", paste0(x, collapse = ", "), "\' ]"); z
---
# /usr/lib/rstudio-server/bin/pandoc/pandoc +RTS -K512m -RTS so.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output so.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/share/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --css "[ 'www/file1.css', 'www/file2.css' ]" --variable "theme:bootstrap" --include-in-header /tmp/RtmpMStG00/rmarkdown-str423c7a02dab7.html --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
Where we unfortunately find --css "[ 'www/file1.css', 'www/file2.css' ]". I have tried a few tricks including: cat, capture.output, as.name, and noquote without luck. An enhancement may be required to rmarkdown to present this in the required form to pandoc.
N.B. It is worth noting this is indeed a duplicate of this question where the answer by Eli Holmes demonstrates the alternate syntax. He also notes a change in the development version, which may include the css field.