Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用jekyll、rmarkdown和github写博客:如何显示图像_R_Jekyll_Knitr_R Markdown - Fatal编程技术网

用jekyll、rmarkdown和github写博客:如何显示图像

用jekyll、rmarkdown和github写博客:如何显示图像,r,jekyll,knitr,r-markdown,R,Jekyll,Knitr,R Markdown,我试着用jekyll、rmarkdown和github三人组写博客(如下所示:) 我的所有.Rmd都在源代码中,我有一个问题,即有时打印是在基本64图像中编织的,有时保存在figure文件夹中 第一个问题,为什么 第二个问题:当我的绘图保存为图像时,html中的路径显示为figure/source/。知道目标文件夹是/blog/(我在_config.yml中的baseurl),要使它工作,它应该是blog/figure/source 奇怪的是,当我用浏览器打开html时,它们会显示在本地。 但是

我试着用jekyll、rmarkdown和github三人组写博客(如下所示:)

我的所有.Rmd都在源代码中,我有一个问题,即有时打印是在基本64图像中编织的,有时保存在figure文件夹中

第一个问题,为什么

第二个问题:当我的绘图保存为图像时,html中的路径显示为figure/source/。知道目标文件夹是/blog/(我在_config.yml中的baseurl),要使它工作,它应该是blog/figure/source

奇怪的是,当我用浏览器打开html时,它们会显示在本地。 但是当我在github上部署我的网站时,图像不会显示,因为路径不正确

如何定义/blog/figure而不是/figure/的路径

编辑:我的博客链接,仍在开发中:

但是Rmd不会出现在github帐户中,因为我与github同步的文件夹是jekyll生成的目标文件

_config.yml:

# Build settings
markdown: kramdown
baseurl: "/blog"
在R中:

build.r:

local({
  # fall back on '/' if baseurl is not specified
  baseurl = servr:::jekyll_config('.', 'baseurl', '/')
  knitr::opts_knit$set(base.url = baseurl)
  # fall back on 'kramdown' if markdown engine is not specified
  markdown = servr:::jekyll_config('.', 'markdown', 'kramdown')
  # see if we need to use the Jekyll render in knitr
  if (markdown == 'kramdown') {
    knitr::render_jekyll()
  } else knitr::render_markdown()

  # input/output filenames are passed as two additional arguments to Rscript
  a = commandArgs(TRUE)
  d = gsub('^_|[.][a-zA-Z]+$', '', a[1])
  knitr::opts_chunk$set(
    fig.path   = sprintf('blog/figure/%s/', d),
    cache.path = sprintf('cache/%s/', d)
  )

  knitr::opts_knit$set(width = 70)
  knitr::knit(a[1], a[2], quiet = TRUE, encoding = 'UTF-8', envir = .GlobalEnv)
})
生成文件:

all:
    Rscript -e "servr::jekyll('..')"

clean:
    rm -r ../blog/

我解决了我的问题,我将其张贴在这里,以防人们有相同的问题:

R中的jekyll()函数使用knitr(我想)编译.md(in_post)中的.rmd(in_source)然后调用jekyll命令

在这里,我的问题是,当我更改了_config.yml文件时,修改了路径,没有重新创建.md,因此路径没有更改

为了让它工作,我必须手动删除源代码中的.md,然后重新运行jekyll()函数

关于图像,当我使用不带缓存的rmarkdown时,它们被编译为64个图像


有了缓存,knitr可以在文件夹中创建图像。

如果能链接到您的github repo,我们将不胜感激。您能将链接添加到您的
\u config.yml
文件吗?它不在你们的GitHub回购协议中,我认为并没有它这个问题是无法解决的。另外,如果您使用生成网站的确切命令,我们将不胜感激。我已经将build.r、makefile和_config.yml放在了这里。谢谢,我试过重现你的问题,但到目前为止我失败了。您是否有机会将整个源目录(无论何时
Makefile
Is的父目录)上传到某个地方?也许是git项目的新分支?此问题解决后,您可以将其删除。目前我唯一的建议是检查
\u posts
目录中的文件,该文件将成为
2015/07/Voronoi\u station.html
。如果此文件中的图像路径错误,则
servr
/
knitr
有故障。如果图像路径正确,则问题与
jekyll
如何处理文件有关。您可能对基于
jekyll now
repo的我的设置感兴趣:从2016年5月开始,它将不受支持,因为github正在放弃红地毯支持,但仍将在本地和支持自定义jekyll设置的其他git页面上工作。
all:
    Rscript -e "servr::jekyll('..')"

clean:
    rm -r ../blog/