I have a project that started out as a single .Rmd file. I published this single page by using rmarkdown::render_site()
and moving the contents of the _site directly to my webserver.
I now need to make several pages which are almost identical except with some minor differences. I tried just making a copy of the index.Rmd file and giving it a new name. However, when I try to build the site I get an error message about duplicate chunk labels. Instead of just renaming each chunk in the new doc as e.g.
{r setup1 ...} # as opposed to just setup
Is there a right way to handle this?
Example script Copy1.Rmd:
---
title: "Home"
output: html_document
site: bookdown::bookdown_site
---
## R Markdown
{r setup}
library(odbc)
the_date <- '2020-04-30'
my_conn <- DBI::dbConnect(odbc(), "Athena")
{sql connection=my_conn, output.var="a_df"}
select *
from schema.table
where date <= ?the_date
{r cars}
str(a_df)
In _site.yml:
---
title: "Example"
navbar:
title: "Example"
left:
- text: "Home"
- href: "index.Rmd"
- text: "Copy1"
- href: "Copy1.Rmd"
- text: "Copy2"
- href: "Copy2.Rmd"
If I want to make multiple copies of the example page above 'Copy1.Rmd' which each generate slightly different output based on the variable the_date
within the chunk called setup, how ca I do that?
If I just make multiple copies and add each new copy as a page to _site.yml I get this error about duplicate chunk names. Once again I could just laboriously rename each chunk in a copied file e.g. setup1, setup2 etc but that seems 'wrong'.
What's the 'right' way to use multiple copies of the same file as different pages in my site?
rmarkdown::render_site(encoding = 'UTF-8')
processing file: _main.Rmd
Error in parse_block(g[-1], g[1], params.src) :
duplicate label 'get_data'
Calls: ... process_file -> split_file -> lapply -> FUN -> parse_block
Please delete _main.Rmd after you finish debugging the error.
Execution halted
Exited with status 1.