rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 335 forks source link

Rendering with full paths #2

Closed dfalbel closed 7 years ago

dfalbel commented 7 years ago

Since I'm deploying gh-pages in a repo (not org.github.io repo), I'm not able to use relative paths. So I'm using hugo -s . to build the site.

By doing this, all assets like javascripts and css are linked with full path: src="https://curso-r.github.io/verao2017/javascripts/application.js" for example.

This doesn't happen with images in Rmd files, they have a strange link: src="#####../content/hello-world/index_files/figure-html/pie-1.png"

How can I make blogdown render the html with baseurl param before the path to image instead of #####../content?

This is my repo: https://github.com/curso-r/verao2017

And I'm using wercker to deploy the public folder to github pages.

Thanks in advance!

dfalbel commented 7 years ago

I fixed by just using: knitr::opts_chunk$set(collapse = TRUE, fig.path = "") in the .Rmd file

Sorry!

yihui commented 7 years ago

Setting fig.path='' is probably not the ideal solution. I have not really started working on resolving paths other than paths for figures and HTML widgets yet, but the recommended way to build your website is not hugo -s in blogdown. I'm still working on the documentation, and typically you use blogdown::serve_site() to live preview your site, and you can just publish the site in the public folder. I'd recommend setting relativeurls to true in config.yaml or config.toml, so that your site will be portable (relative URLs everywhere so you can move your site wherever you want). Hugo seems to favor absolute paths, but I don't think it is a good idea.

yihui commented 7 years ago

FYI, I have renamed render_pages() to build_site() and exported it. You should not need to set fig.path.

dfalbel commented 7 years ago

Thanks! This will work great!

dfalbel commented 7 years ago

I think it's not exported yet :)

yihui commented 7 years ago

Indeed. Sorry about that. Just exported it.