Reputation: 23
I am completely new to Rmarkdown and blogdown and I am having a hard time understanding how does .markdown, .Rmarkdown, .Rmd et .md etc... files are produced and, in some ways, are different working with Rstudio.
To be more specific, I am building a website with Hugo Apéro theme in Rstudio, hence with blogdown and Rmarkdown files.
I want to create a series of blogposts related to one another and with the TOC on the left side of the page just like Alison Hill did in her own blog here
In theory, this is not so hard and I managed to write the firsts blog posts in my own series with some math equations and everything that I wanted with some .Rmd files.
This is were it gets tricky, when I knit the said .Rmd files it produces only one .html file. I cannot find a way to produce the .md file necessary for hugo and/or blogdown (I do not really know what does what up to here) to produce the TOC of one specific blogpost. Looking at Alison Hill's blog posts it corresponds to the On this page TOC.
I know that Rstudio v2 need some work around to produce the .html and .md file (see this very specific question here) however, none of the proposed solutions seem to work for me.
I managed to produce an .markdown file from a .Rmarkdown file which render the TOC like I want, however, .Rmarkdown files are not the best for math rendering, (see Creating Websites with R Markdown - Ch1.5), are not created in Rstudio etc... which does not make me want to use this format (maybe that is a mistake ?)
The absence of TOC in the final page seem related to another element : a headers link button. Still, looking at Alison Hill's blog posts I notice a link button next to each headers that I do not have if I work with .Rmd file (which produce only .html file) but they appears with the .Rmarkdown file (which produce only .md file)
So I guess my question is :
How can I include a TOC from the .Rmd file ?
How can I create a .md file from .Rmd file in Rstudio ? and why none of these solutions work for me :
keep_md = TRUE
in html_document()
rmarkdown::render()
with clean = FALSE
md_document
as one of your output formatsAlso, in working on my blog post I wanted to create pannelsets like in Hugo Apero documentation and it does not work with the first syntax in a .Rmd file :
`{{< panelset class="greetings" >}}
{{< panel name="Hello! :wave:" >}}
hello
{{< /panel >}}
{{< panel name="Goodbye :dash:" >}}
goodbye
{{< /panel >}}
{{< /panelset >}}`
It only works with the HTML code as provided in the documentation. I guess this is not a normal behaviour.
For more info, here is the result of sessionInfo() :
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 bookdown_0.24 ps_1.6.0 later_1.3.0 digest_0.6.29
[6] R6_2.5.1 jsonlite_1.7.2 magrittr_2.0.1 evaluate_0.14 blogdown_1.6
[11] stringi_1.7.6 rlang_0.4.12 promises_1.2.0.1 rstudioapi_0.13 rmarkdown_2.11
[16] tools_4.1.2 stringr_1.4.0 servr_0.24 processx_3.5.2 httpuv_1.6.3
[21] xfun_0.29 yaml_2.2.1 fastmap_1.1.0 compiler_4.1.2 htmltools_0.5.2
[26] knitr_1.37
Upvotes: 1
Views: 375
Reputation: 30174
To generate .md
from .Rmd
posts, you need to set
options(blogdown.method = 'markdown')
in your .Rprofile
. See Section 1.4 of the blogdown book for more info.
And don't forget to delete the .html
output files.
Alternatively, use the extension .Rmarkdown
instead of .Rmd
, which also gives you Markdown output instead of HTML.
Upvotes: 3