Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difference between preview in RStudio Viewer pane and browser window #490

Closed
werkstattcodes opened this issue Oct 13, 2020 · 9 comments
Closed

Comments

@werkstattcodes
Copy link

Many thanks for this wonderful package!

I just updated to blogdown 0.21 and noticed a behavior which seems quite odd to me. I hope I didn't miss any
related info, but it seems this something new:

  1. I made changes to my .css file.
  2. I reopened RStudio, the blog was rendered with blogdown:::preview_site(startup = TRUE). The changes to the css are visible in RStudio's Viewer pane. Hence, all fine.
  3. I click on 'show in new window' in RStudio's Viewer pane to see the blog in my browser (chrome).
  4. The browser opens. but the changes to the css are no longer visible. Even after refreshing; reopening browser etc. I used the 'inspect' tool to check both the file in the viewer and in the browser. It seems as if these are effectively not the same file.

Any idea? Many thanks.

@cderv
Copy link
Collaborator

cderv commented Oct 13, 2020

Hi @werkstattcodes, can you share an example so that is easier for me to reproduce and investigate ?

The css you modified is in static/ or in the theme/ folder ?

Thank you.

@cderv
Copy link
Collaborator

cderv commented Oct 13, 2020

I can't reproduce for now. What I did:

  • New blogdown website with default theme yihui/hugo-lithium
  • Add a CSS mycss.css in static folder with simple css
h1 {
  color: red;
}
  • Add in config.toml under [params] :
    customCSS= ["mycss.css"]

The viewer and the browser are correctly updated.

@werkstattcodes
Copy link
Author

Hi,

many thanks for the quick response.

The changed css is located in themes/hugo-theme-basic/static/css/
https://github.com/werkstattcodes/blog

I didn't encounter the issue before updating blogdown.
Just restarted the computer etc. Issue remains.

r

@werkstattcodes
Copy link
Author

just to update - i also created a new test blog as you suggested. Indeed, the issue does not arise. Must be something specific to my blog.

@cderv
Copy link
Collaborator

cderv commented Oct 13, 2020

I think it could be related to how you browser is caching or not the resources. Often, there is a caching mechanism in memory to speed up website loading when you are surfing the web.

As you are using chrome, you can open Devtools Pane (F12), go into Network Tab and reload the page and see if the css is loaded from memory or not.

See here on column size
image

You maybe can close your browser or deactivate the cache (always or just when you are working on your website)
See the checkbox Disable Cache
image

Can you try that and tell me if that helps ?

@werkstattcodes
Copy link
Author

yes, after checking 'disable cache' the changes to the css become visible in the browser. many thanks!

i don't know whether it's related: When I click in the viewer pane on some links in my blog, the blog opens in the browser. I can't navigate through the blog in the viewer pane. However, in the dummy blog set up earlier (hugo-lithium theme), I can navigate without being directed to the browser window. Not sure whether this is relevant. Just an oddity. In any case, thanks again!

@cderv
Copy link
Collaborator

cderv commented Oct 13, 2020

i don't know whether it's related: When I click in the viewer pane on some links in my blog, the blog opens in the browser. I can't navigate through the blog in the viewer pane. However, in the dummy blog set up earlier (hugo-lithium theme), I can navigate without being directed to the browser window. Not sure whether this is relevant. Just an oddity. In any case, thanks again!

I don't think this is relative. It may come from your blogdown theme and the use of relative url. Normally, serve_site will insure hugo is run with relative url activated, but I guess there could be theme dependent stuff happening.

Anyway, unfortunatly, I think this is specific to your website and not a blogdown issue per-se. I'll close this issue, but feel free to open a new one for this specific issue if you want further help on this. Thanks!

@cderv cderv closed this as completed Oct 13, 2020
@yihui
Copy link
Member

yihui commented Oct 13, 2020

When I click in the viewer pane on some links in my blog, the blog opens in the browser.

@werkstattcodes Normally this shouldn't happen, but it's up to the theme authors whether they use Hugo's relURL function to make sure URLs are relative. If a URL contains the full domain and protocol (like https://www.example.org/path/to/file/ instead of /path/to/file), it may be opened in the external browser.

One thing you could try is set relativeURLs to true in your config file.

BTW, I guess you do not have to disable cache entirely, but could try "force refresh" (Cmd + Shift + R on macOS---not sure what it is on Windows; perhaps Ctrl + F5).

@cderv
Copy link
Collaborator

cderv commented Oct 13, 2020

not sure what it is on Windows; perhaps Ctrl + F5

MAJ+F5 in chrome or CTRL+MAJ+R will work also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants