【问题标题】:Rmarkdown html add metaRmarkdown html 添加元
【发布时间】:2020-03-18 17:10:39
【问题描述】:

我们正在尝试创建一个非常简单的关于冠状病毒统计信息的网页 (corona-stat.lt)。我们基本上在 Rstudio 中使用 .Rmd --> html 编写 Rmarkdown(这里是源代码at GitHub)。有谁知道,如果有一种方法来定义 html 元,这样我们就可以有

<meta property="og:url" content="corona-stat.lt" />
<meta property="og:site_name" content="Corona-Stat.lt" />
<meta property="og:image" content="https://raw.githubusercontent.com/justasmundeikis/corona-stat-lt/master/figures/corona-stat-logo.png" />
<meta property="og:type" content="page" />

index.Rmd 文件内部,但不破坏flatly theme 的html 代码?我知道,我可能可以手动更改 index.html 文件,但是每次更新时都太繁琐了。

谢谢。

【问题讨论】:

    标签: r-markdown knitr


    【解决方案1】:

    您可以使用metathis 包。

    这是一个根据文档的基本示例:

        ```{r, echo=FALSE}
    
    #install the library before calling it
    
    library(metathis)
    
    meta() %>%
      meta_description(
        "This book will teach you how to do data science with R..."
      ) %>% 
      meta_name("github-repo" = "hadley/r4ds") %>% 
      meta_viewport() %>% 
      meta_social(
        title = "R for Data Science",
        url = "https://r4ds.had.co.nz",
        image = "https://r4ds.had.co.nz/cover.png",
        image_alt = "The cover of the R4DS book",
        og_type = "book",
        og_author = c("Garrett Grolemund", "Hadley Wickham"),
        twitter_card_type = "summary",
        twitter_creator = "@hadley"
      )
    ```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-23
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 2017-10-06
      • 1970-01-01
      相关资源
      最近更新 更多