rstudio / blogdown

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

Support for shiny runtime? #12

Closed mwillumz closed 7 years ago

mwillumz commented 7 years ago

I'm curious whether there'll be support for shiny apps. I tried copying the public directory to a shiny server. The blog sorta rendered but relative links seemed broken and couldn't run a basic shiny app.

Just curious. I've been starving for this and am already migrating away from Jekyll. Thanks!

yihui commented 7 years ago

I'm still working on the documentation, and the problem of relative links is a very tricky one. Not all Hugo themes are friendly to relative links, and Hugo itself seems to be in favor of absolute links, which is something I don't like.

Anyway, you have two choices:

  1. If you want relative links, be sure to add relativeurls = true to config.toml (or equivalently relativeurls: yes in config.yaml); again, it is up to your Hugo theme whether relative links are well supported. Then the public directory can be moved to the www directory of a shiny app. But actually I don't see the point of serving a static website through Shiny.
  2. Or use absolute links by setting baseurl in config.toml/yaml and build the site with blogdown:::hugo_cmd(). The problem is whether baseurl is fixed. For example, in a local Shiny app, the base URL can be random like http://127.0.0.1:xxxx where xxxx is a random port.

If you want to include Shiny apps in your website, I strongly recommend that you publish the app elsewhere instead of hosting the whole website as an app (Shiny was not designed as a web server primarily). For example, if you publish to ShinyApps.io, you can use knitr::include_app() to embed the app on a web page.

mwillumz commented 7 years ago

Thanks for your prompt reply. This is good guidance.