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

How to publish a html_resume on a blogdown blog? #223

Closed
MengranLi-git opened this issue Apr 17, 2021 · 10 comments
Closed

How to publish a html_resume on a blogdown blog? #223

MengranLi-git opened this issue Apr 17, 2021 · 10 comments
Labels
question

Comments

@MengranLi-git
Copy link

@MengranLi-git MengranLi-git commented Apr 17, 2021

I just opened a CV template of pagedown, but other templates from pagedown performed alike.

when I use knit: pagedown::chrome_print()

it reports:

Error in find_chrome() :
Cannot find Google Chrome automatically from the Windows Registry Hive. Please pass the full path of chrome.exe to the 'browser' argument or to the environment variable 'PAGEDOWN_CHROME'.
Calls: -> find_chrome
Execution halted

If I didn't use chrome_print, it will generate a blank HTML, or display disorderly. However, it can render perfectly in R session preview.

@RLesur
Copy link
Collaborator

@RLesur RLesur commented Apr 17, 2021

IMO, there are two different problems.

The first one is related to chrome_print(): chrome_print() does its best to find Chrome or Chromium automatically. Depending on your configuration this step might not succeed. That's why you get "Cannot find Google Chrome automatically from the Windows Registry Hive".

The error message also gives a hint to fix this problem:

  • first, check that Chrome or Chromium is available on your system
  • if Chrome is already installed, you have to find the path to Chrome or Chromium executable (if you're not familiar with this task you can find some tutorials on the web)
  • once you get this path, you have to create an environment variable named PAGEDOWN_CHROME whose value will be this path (see https://rstats.wtf/r-startup.html#renviron if you're not familiar with environment variables)

For, the second problem (a blank or disordered HTML), I wonder whether you used a local web server as explained in the documentation (see https://pagedown.rbind.io/#preview-paged-html-documents).

@MengranLi-git
Copy link
Author

@MengranLi-git MengranLi-git commented Apr 17, 2021

IMO, there are two different problems.

The first one is related to chrome_print(): chrome_print() does its best to find Chrome or Chromium automatically. Depending on your configuration this step might not succeed. That's why you get "Cannot find Google Chrome automatically from the Windows Registry Hive".

The error message also gives a hint to fix this problem:

  • first, check that Chrome or Chromium is available on your system
  • if Chrome is already installed, you have to find the path to Chrome or Chromium executable (if you're not familiar with this task you can find some tutorials on the web)
  • once you get this path, you have to create an environment variable named PAGEDOWN_CHROME whose value will be this path (see https://rstats.wtf/r-startup.html#renviron if you're not familiar with environment variables)

For, the second problem (a blank or disordered HTML), I wonder whether you used a local web server as explained in the documentation (see https://pagedown.rbind.io/#preview-paged-html-documents).

Thanks for your reply! The first issue has been solved pretty well. For the second question, yes I used a real local web server. If I use "Infinite Moon Reader" in the xaringan package, it is normal. But I'd like to put the HTML document on my blog (established by blogdown), it performs disordered. Is there any way to solve this issue?

@RLesur
Copy link
Collaborator

@RLesur RLesur commented Apr 17, 2021

Thanks a lot for your reply!

I understand much better why your resume is disordered when you try to publish it on your blogdown blog. Maybe can you try to produce a self contained HTML page (with self_contained: true)?

I haven't had any occasion to work with blogdown recently, so maybe @cderv, @apreshill or @yihui have a better idea.

@RLesur RLesur changed the title Error in find_chrome() How to publish a html_resume on a blogdown blog? Apr 17, 2021
@MengranLi-git
Copy link
Author

@MengranLi-git MengranLi-git commented Apr 17, 2021

Thanks a lot for your reply!

I understand much better why your resume is disordered when you try to publish it on your blogdown blog. Maybe can you try to produce a self contained HTML page (with self_contained: true)?

I haven't had any occasion to work with blogdown recently, so maybe @cderv, @apreshill or @yihui have a better idea.

Have tried self_contained: true
Error: pandoc document conversion failed with error 99

@RLesur
Copy link
Collaborator

@RLesur RLesur commented Apr 17, 2021

Error: pandoc document conversion failed with error 99

This error is often associated with a wrong working directory or images locations. You may find some informations to solve this problem on RStudio Community (see here or here for instance).

@cderv
Copy link
Collaborator

@cderv cderv commented Apr 19, 2021

But I'd like to put the HTML document on my blog (established by blogdown), it performs disordered. Is there any way to solve this issue?

@MengranLi-git How are you putting it on your blog ? Can you share or point to an example ?

For specific output format, you should follow the static files advice: https://bookdown.org/yihui/blogdown/static-files.html

  • Create a folder in static/
  • render your document in this folder as HTML
  • they will be included in the website using a path <site_url>/<folder-in-static>

I tried it a demo blog:

  • I created a static directory
  • In this directory, I created a resume directory.
  • In this directory I created a new pagedown HTML resume using the template in RStudio IDE and named it index.Rmd - I have static/resume/index.Rmd - I leave the self_contained = FALSE in this document
  • I knit this document - this will built a static/resume/index.html

Then when I preview or build the hugo site, if I add the resume/ endpoint in my website main url then I can see the html_resume() from pagedown. Locally in preview, this is http://localhost:4321/resume/

Have you tried something like this alread ?

Hope it helps

@MengranLi-git
Copy link
Author

@MengranLi-git MengranLi-git commented Apr 19, 2021

But I'd like to put the HTML document on my blog (established by blogdown), it performs disordered. Is there any way to solve this issue?

@MengranLi-git How are you putting it on your blog ? Can you share or point to an example ?

For specific output format, you should follow the static files advice: https://bookdown.org/yihui/blogdown/static-files.html

  • Create a folder in static/
  • render your document in this folder as HTML
  • they will be included in the website using a path <site_url>/<folder-in-static>

I tried it a demo blog:

  • I created a static directory
  • In this directory, I created a resume directory.
  • In this directory I created a new pagedown HTML resume using the template in RStudio IDE and named it index.Rmd - I have static/resume/index.Rmd - I leave the self_contained = FALSE in this document
  • I knit this document - this will built a static/resume/index.html

Then when I preview or build the hugo site, if I add the resume/ endpoint in my website main url then I can see the html_resume() from pagedown. Locally in preview, this is http://localhost:4321/resume/

Have you tried something like this alread ?

Hope it helps

Thank you for your reply! In the link http://localhost:4321/resume/, it displays well. But I'd like to add the HTML link in a page. The path is /content/authors/Mengran-Li. There is a _index.md document where I'd like to add a link to CV. In this _index.md document, I write [PDF](Resume.pdf), it works. But if I write [HTML](Resume.html) , it displays as 404. If I specify the path to /static/resume/index.html, there will be the same result (I have created the documents in static/)

@cderv
Copy link
Collaborator

@cderv cderv commented Apr 20, 2021

But if I write HTML , it displays as 404. If I specify the path to /static/resume/index.html, there will be the same result (I have created the documents in static/)

The link will be the same as you type in your browser. So if http://localhost:4321/resume/ works,
the link to use will be [HTML](/resume/). When doing inserting link, you need to understand relative vs absolute. I used absolute link here, but you could also use relative. See https://bookdown.org/yihui/blogdown/html.html where this is explain.

Also, everything in static/ will be available at root of your site when served. So static should not be included in the link.

About "But if I write HTML " : we called the Rmd index.Rmd into a resume/ folder so Resume.html does not exists. You need to link to the html page that exists. You can change url (path and name) of this file by changing how you set it in static/ folder.

@MengranLi-git
Copy link
Author

@MengranLi-git MengranLi-git commented Apr 20, 2021

/resume/

I knew what the problem was. The issue has been solved! Thank you very much for your reply and for helping me understand the structure!

@cderv
Copy link
Collaborator

@cderv cderv commented Apr 20, 2021

You're welcome ! Glad it works now!

@cderv cderv closed this as completed Apr 20, 2021
@cderv cderv added the question label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question
Projects
None yet
Development

No branches or pull requests

3 participants