【发布时间】:2015-12-23 22:43:38
【问题描述】:
我尝试使用三重奏 jekyll、rmarkdown 和 github 来写博客(如这里:http://yihui.name/knitr-jekyll/)
我的所有 .Rmd 文件都保存在 _source 中,但我遇到的问题是,有时绘图是在 base 64 图像中编织,有时保存在图形文件夹中。
第一个问题,为什么?
第二个问题:当我的情节保存为图像时,html中的路径似乎是图/源/。知道目标文件夹是 /blog/(我在 _config.yml 中的 baseurl),要使其工作,它应该是 blog/figure/source。
奇怪的是,当我用浏览器打开 html 时,它们会在本地显示。 但是当我在github上部署我的网站时,由于路径不正确,图像没有显示出来。
如何定义 /blog/figure 而不是 /figure/ 的路径?
编辑:我博客的链接,仍在开发中: http://yvescr.github.io/
但是 github 账户中没有出现 Rmd,因为我与 github 同步的文件夹是 jekyll 生成的目标文件。
_config.yml:
# Build settings
markdown: kramdown
baseurl: "/blog"
在 R 中:
jekyll(dir = ".", input = "_source", output = "_posts", script = c("Makefile", "build.R")
, command = "jekyll build --destination ../blog")
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/
【问题讨论】:
-
您的 github 存储库的链接将不胜感激。
-
您可以添加指向您的
_config.yml文件的链接吗?它不在您的 GitHub 存储库中,我认为没有它就无法解决问题。此外,您用于生成网站的确切命令将不胜感激。 -
我已经把 build.r、makefile 和 _config.yml 放好了。谢谢
-
我已经尝试重现您的问题,但到目前为止我失败了。您是否有机会在某处上传整个源目录(
Makefile的父目录)?也许作为 git 项目的新分支?解决此问题后,您可以将其删除。目前我唯一的提示是检查_posts目录中的文件,该文件将变为2015/07/Voronoi_station.html。如果此文件中的图像路径错误,则servr/knitr有问题。如果那里的图像路径正确,则问题与jekyll处理文件的方式有关。 -
您可能对我基于
jekyll-nowrepo: jangorecki.github.io/blog/2014-11-05/Hello-World.html 的设置感兴趣,因为 github 正在放弃 redcarpet 支持,因此从 2016 年 5 月开始将不再支持它,但仍可在本地和其他平台上运行支持自定义 jekyll 设置的 git 页面。
标签: r jekyll knitr r-markdown