yihui/servr

File Path issue with servr::jekyll

Closed this issue · 6 comments

When converting from Rmd -> md files the file path for figures is missing a /

this does not occur when calling servr::jekyll() from an R session, however if one calls jekyll serve from bash, one cannot find the image.

looking at the md file I notice this:

![plot of chunk unnamed-chunk-1](/mysitefigure/source/2016-04-17-test/unnamed-chunk-1-1.png)

whereas the code should read:

![plot of chunk unnamed-chunk-1](/mysite/figure/source/2016-04-17-test/unnamed-chunk-1-1.png)

If I manually change the md file, this issue goes away

If one changes the base url in _config.yml to "/mysite/" it works, but I believe that this is not correct (jekyll serve now says Server address: http://127.0.0.1:4000/mysite//

yihui commented

You didn't bring a minimal reproducible example, so all I can do is guess, and my guess is you didn't set the option correctly, e.g. you should

knitr::opts_knit$set(base.url = '/mysite/')

and for some reason, you probably ended up with

knitr::opts_knit$set(base.url = '/mysite')

i specify the base url in the _config.yml file, which is read by build.R
according to the example supplied by jekyll, the baseurl in _config.yml should not include the final /
#baseurl: /path/to/blog
not
#baseurl: /path/to/blog/

however I believe that this issue may be with the build.R script in your other repo here, and not in this repo. sorry.

yihui commented

Okay, I'll fix the _config.yml in the other repo. Thanks!

I don't know much about servr, knitr, jekyll, etc., but this problem is preventing me from publishing my blog, so I tried the following and it didn't help:

on line 91 of dynamic.R, pass in argument paste0(baseurl, '/') as the baseurl parameter, instead of local variable baseurl.

Just mentioning this in case it is helpful to those who know more about the situation than I do.

I also noticed the build_jekyll function is never called.

OK, I made a very kludgey patch, but it does work....

https://github.com/rcorty/CortyKit/blob/master/R/servr_patch.R