Reputation: 12142
I am creating an R Markdown website. However, I am having problems setting the style of the output styling for the document.
I have the _site.yml
with output arguments that looks like:
output:
bookdown::html_document2:
toc: true
toc_float: true
theme: flatly
highlight: tango
df_print: paged
include:
in_header: "header.html"
after_body: "footer.html"
css: "./assets/style.css"
And I have a few .Rmd files in the same directory that have simple YAML matter:
---
title: "A title"
subtitle: "A subtitle"
author: "Name"
---
I render the site rmarkdown::render_site()
. The site and the pages work, but the rendered .Rmd files do not show the settings (toc, theme, highlight etc) and css styles defined in the _site.yml
file. The header and footers also do not show. The path/location of header.html,footer.html and style.css has been verified.
Do I have to specify the output settings in every .Rmd file?
Upvotes: 0
Views: 1323
Reputation: 15419
The problem appears to come from the use of bookdown::html_document2
instead of the rmarkdown function html_document
.
Using the template provided by RStudio here, I made some one edit to the settings, adding theme: flatly
:
name: "my-website"
navbar:
title: "My Website"
left:
- text: "Home"
href: index.html
- text: "About"
href: about.html
output:
html_document:
highlight: textmate
theme: flatly
include:
after_body: footer.html
css: styles.css
Replacing html_document
with bookdown::html_document2()
Looking through the source code of the render_site
function, there appears no way for it to parse any other output than html_document
. In fact, when bookdown::html_document2()
is provided, it will overwrite the _site.yml
file to:
name: my-website
navbar:
title: My Website
left:
- text: Home
href: index.html
- text: About
href: about.html
output:
html_document:
lib_dir: site_libs
self_contained: no
output_dir: _site
If you are looking to benefit from using
html_documents2
within your website, you should check out blogdown.
Upvotes: 1