.yml中的设置不会显示在渲染的.Rmd中 [英] Settings in .yml do not show up in rendered .Rmd

查看:37
本文介绍了.yml中的设置不会显示在渲染的.Rmd中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个

bookdown :: html_document2()

替换 html_document

浏览 源代码> render_site 函数,除 html_document 之外,没有其他方法可以解析任何其他输出.实际上,当提供 bookdown :: html_document2()时,它将把 _site.yml 文件覆盖为:

 名称:我的网站导航栏:标题:我的网站剩下:-文字:首页href:index.html-文字:关于href:about.html输出:html_document:lib_dir:site_libs独立的:否output_dir:_site 

如果您希望从网站中使用 html_documents2 受益,则应查看 blogdown .

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?

解决方案

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.

这篇关于.yml中的设置不会显示在渲染的.Rmd中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆