我有一个包含三个文件的网站。
_site.yml
name: Website
navbar:
title: Website
right:
- text: Home
- text: Info
output:
html_document:
theme: flatly
highlight: tango
index.Rmd
---
title: Welcome
output:
html_document:
theme: united
highlight: textmate
---
This is the index.
test.Rmd
---
title: Test
output:
html_document:
theme: united
highlight: textmate
---
This is the test file.
```{r}
2+2
如果我运行rmarkdown::render("test.Rmd")
,我会得到一个包含网站标题的超文本标记语言。这类似于运行rmarkdown::render_site()
的输出。
如果我删除_site.yml
文件并运行相同的命令,我会得到常规的HTML输出:
因此,如果存在,render()
必须使用_site.yml
。可以禁用此功能吗?我想创建一个常规的超文本标记语言输出,即使_site.yml
文件存在。这是一个特别的问题,当我有xaringan演示文稿时,我不希望它们与网站标题一起呈现。
发布于 2019-05-10 03:46:13
我不认为有一种方法可以在rmarkdown
中禁用它,但您可以尝试以下解决方法来暂时重命名它,然后再重新命名它:
render_without_site_yml <- function(input, ...) {
dir <- dirname(input)
site_yml <- file.path(dir, "_site.yml")
if (file.exists(site_yml)) {
newname <- file.path(dir, "_site.yml.save")
if (file.exists(newname))
stop("'_site.yml.save' exists!")
file.rename(site_yml, newname)
on.exit(file.rename(newname, site_yml))
}
rmarkdown::render(input, ...)
}
https://stackoverflow.com/questions/56064050
复制相似问题