I try to do a blog using the trio jekyll, rmarkdown and github (as here: http://yihui.name/knitr-jekyll/)
I have all my .Rmd in _source, and I have this issue that sometimes the plots are knit in base 64 images and sometimes saved in a figure folder.
First question, why?
Second question: when my plot are saved as images, the path in the html appear to be figure/source/. Knowing that the destination folder is /blog/ (my baseurl in _config.yml), to make it work, it should be blog/figure/source.
Strangely, they are displayed locally and when I open the html with my browser. But when I deploy my website on github, the images aren't displayed, as the path is incorrect.
How to define the path to /blog/figure instead of /figure/ ?
Edit: the link to my blog, still in development: http://yvescr.github.io/
But the Rmd don't appear in the github account, as the folder I synchronised with github is the destination file of the jekyll generation.
_config.yml:
# Build settings
markdown: kramdown
baseurl: "/blog"
In 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)
})
makefile:
all:
Rscript -e "servr::jekyll('..')"
clean:
rm -r ../blog/
_config.yml
file? It's not in your GitHub repo and I don't think issue can be solved without it. Also, the exact command that you use to generate your website would be appreciated.Makefile
is) somewhere? Maybe as new branch of git project? You can delete it once this problem is solved. At the moment the only tip I have is to check_posts
directory for file that will become2015/07/Voronoi_station.html
. If image path is wrong in this file, thenservr
/knitr
is at fault. If image path is correct there, then problem is related to howjekyll
processes files.jekyll-now
repo: jangorecki.github.io/blog/2014-11-05/Hello-World.html it won't be supported starting from May 2016 as github is dropping redcarpet support, but will still work locally and on other git pages which supports custom jekyll setup.