# Not working in RStudio Server #124

Closed
opened this Issue Jun 19, 2017 · 20 comments

Projects
None yet
5 participants

### nwstephens commented Jun 19, 2017

 Blogdown for R Views not working in RStudio Server Pro.
Member

### yihui commented Jun 19, 2017

 It works only if you set relativeurls = true in config.toml.

### nstrayer commented Aug 30, 2017

 What's the protocol for dealing with static files in this context? When running rstudio server on port 8787 when rstudio spins up a server instead of putting out on a different port it appends it to the url ...:8787/p/ which is breaking links to all static files. ( I have relativeurls = true set). Let me know if you need a more concrete code example.
Member

### yihui commented Aug 30, 2017 • edited

 @nstrayer You are right that the proxy mechanism /p// introduced the problem. Setting relativeurls = true does not always work, because it is up to the theme author whether the theme really supports relative URLs consistently throughout the theme, which means the author must use the Hugo function relURL for all URLs and the variable .URL instead of .Permalink. Unfortunately, from what I can see, many theme authors didn't notice the importance of this, so your website may still contain absolute URLs, which fail to work with RStudio Server. As an example, you can take a look at the hugo-xmin theme that I wrote to see how relURL and .URL work:

### nstrayer commented Aug 30, 2017 • edited

 How would this work when implementing the file path in a post? For instance I want to include an image via the standard ![](/images/myImage.png) syntax. Is there an option in the theme settings for converting those using the relURL function? The example i'm referring to, on my rstudio server instance I'm running with blogdown::serve_site() and the blog logo (generated by the following partial) 

{{if .IsHome}} {{if .Site.Params.showtitle}} {{.Site.Title}} {{end}} {{end}}

 works great, but the images included in a post generated by this markdown ## Image test ![](/images/bite_laptop.png) 

### nstrayer commented Aug 30, 2017 • edited

 Interestingly the url does appear to be pointing where i'd expect. This points to ...8787/p//images/bite_laptop.png.
Member

### yihui commented Aug 30, 2017

 When relativeurls = true, Hugo does generate relative URLs in the body of a post. The main problem comes from the theme. Hugo won't convert URLs from the theme (e.g. those URLs for CSS in ).

### nstrayer commented Aug 30, 2017 • edited

 I see. I just got everything to work a-ok when I explicitly added canonifyURLs = false to the config.toml. I must have had an older version of hugo installed. Thanks a ton for your help, I will be going through tuftesque to make sure I properly implemented relURL everywhere now!

Closed

Closed

Closed

### gauravsatav commented Nov 28, 2017

 Hi guys, I see that this issue is still open here but just wanted to perform a quick check to know if any solution/workaround been found for this issue yet. I am trying to create a simple blog (with the default lithium theme) but as mentioned in the post above, the links for the website are not forming properly. I had then manually added the relativeurls = true option to the config.toml file and am still facing the issues of broken links. Also wanted to check if this issue is begin faced by everyone using RStudio Server. Thanks again

### nstrayer commented Nov 28, 2017 • edited

 I managed to get everything working on rstudio server by adding url({{ | relURL}}) to pretty much any url I could find in addition to adding relativeurls = true in the config.toml. I had to change a bunch of stuff in my own custom theme too so perhaps you are using a theme that doesn't have these implemented?

### gauravsatav commented Nov 28, 2017 • edited

 Hi Nick, thanks for the reply. As I had previously mentioned I am using the default lithium theme. I would just like to understand when you say you've added the url({{ | relURL}}) option to all the urls, to which files have you added these changes to? Is it only in the config.toml file? This is how my config file looks: relativeurls=true languageCode = "en-us" title = "A Hugo website" theme = "hugo-lithium-theme" googleAnalytics = "" disqusShortname = "" ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"] [permalinks] post = "/:year/:month/:day/:slug/" [[menu.main]] name = "About" url = "/about/" [[menu.main]] name = "GitHub" url = "https://github.com/rstudio/blogdown" [[menu.main]] name = "Twitter" url = "https://twitter.com/rstudio" [params] description = "A website built through Hugo and blogdown." # options for highlight.js (version, additional languages, and theme) highlightjsVersion = "9.11.0" highlightjsCDN = "//cdn.bootcss.com" highlightjsLang = ["r", "yaml"] highlightjsTheme = "github" MathJaxCDN = "//cdn.bootcss.com" MathJaxVersion = "2.7.1" [params.logo] url = "logo.png" width = 50 height = 50 alt = "Logo" 
Member

### yihui commented Nov 28, 2017

 @gauravsatav If you are using the default theme, all you need to do is set relativeurls = true in config.toml.

### gauravsatav commented Nov 28, 2017 • edited

 @yihui as a result of setting the relativeurls=true parameter I am able to see the main index page within the public directory /public/index.html page properly however the links to all the rest of the files is still proving to be an issue. For example the link for About page is directed only to the /public/about/ directory rather than to the file /public/about/index.html

### nstrayer commented Nov 28, 2017

 @gauravsatav Oops, sorry I missed the part about you using the lithium theme. When I say I changed those URLs I mean that I changed them in all the files in my layouts/ folder.
Member

### yihui commented Nov 28, 2017

 @gauravsatav Are you using the Serve Site addin? You should always use it.

### gauravsatav commented Nov 28, 2017 • edited

 Server Site addin ? I'm sorry I don't know what that is. I was simply following the instruction for creating a new blog directly using the new_site() command. Could you shed some light on the addin ? @nstrayer my /layouts folder seems to be empty I just now used the serve_site() command and the rebuild my site using build_site(). Still not able to link up those pages.
Member

### yihui commented Nov 28, 2017

 @gauravsatav I understand that you may be busy, but you need to read at least the Chapter 1 of the blogdown book: https://bookdown.org/yihui/blogdown/ Since you are using the RStudio IDE, there is no need to call any functions in blogdown explicitly. For example, if you want to create a new project, you can do so simply by clicking the menu (see Section 1.3 in the book). Then use the Serve Site addin.

### gauravsatav commented Nov 28, 2017

 I am really sorry for asking that, actually I had read the book but I failed to recollect it. But I must admit that after reading the article (along with the rest of the book) It seems that the purpose of serve_site() is to reload the site to reflect the recent change made in the code. I too was doing the same thing (although manually) by using build_site(). I am still unable to resolve the issue Any ways I really really appreciated your time on this. Thanks again
Member

### yihui commented Nov 28, 2017

 Restart your R session. Set relativeurls = true in config.toml. Serve Site. Unless you really understand what build_site() does, please do not use it. If you follow the recommended workflow, you never need build_site(): https://bookdown.org/yihui/blogdown/workflow.html

### lponnala commented Jan 2, 2018

 I can confirm that Yihui's solution works perfectly. I am using blogdown with the xmin theme on rstudio-server. All I had to do was set relativeurls = true in config.toml. And the preview showed up just fine!

Open

Closed

Member

### yihui commented Jan 21, 2019

 I have set relativeURLs = true automatically when a site is being previewed in RStudio Server. As I said above (#124 (comment)), it really depends on the theme author whether this method works or not.