Thanks for your great work on this package!
Very small question, which might be a GitHub thing we can't do anything about.
I've got a presentation set up to pull from my docs directory. I added a favicon to the project root and it displayed when rendered locally in Chrome.
However, it doesn't display on GH pages (second tab).

I tried adding some link tags which wasn't necessary for the favicon to display locally, but no dice.
Not sure where exactly the favicon code needs to be stored to also get displayed by GH pages. You can try to search in the _pkgdown_ repo how it is handled there.
Even if it would work, creating the slides again would overwrite the references to the favicon, wouldn't it?
I can't help out much here, but I have used favicons in Rmd generated websites. Usually there is something in the yaml front matter like this:
favicon: images/favicon.png
Which then includes a link in the html output.
<link rel="icon" type="image/png" href="images/favicon.png"/>
It seems like this is something that could be implemented in xaringan.
Two suggestions: First, from browsing your repo, it seems like the favicon didn't make it into docs. I'd say there's a good chance this is the problem, as I don't think GitHub pages "sees" anything outside the folder/branch from which the pages are served.
But if that doesn't work, then maybe the link tag isn't making it into <head> and this could be the problem?
In which case, I'm pretty sure that you can use includes as an option of moon_reader in the YAML header to pass an HTML file as in_header, ala html_document(), as in something like this:
output:
xaringan::moon_reader:
css: ["default", "shinobi", "dobbs.css"]
lib_dir: libs
includes:
in_header: header.html
nature:
...
Btw, I've really been wanting to learn drake and your slides are π₯π₯π₯ and thanks for opening this issue so I could discover them! π
Thanks for these great suggestions, all!
@gadenbuie glad you're a fan of the slides :) Your point that GH pages probably doesn't see anything outside docs makes a lot of sense.
I tried copying the favicon to docs with no luck. Then gave your suggestion of adding a header file and the corresponding includes a shot.
I could be wrong here but it doesn't seem like in_header is an option in xaringan?
So off that, next tried specifying it as a before_body with head tags. No luck.
Thanks @pat-s for the point about looking into how pkgdown handles favicons. I would have to do more digging to really get how pkgdown works but from a first pass it looks like you can build your own from your logo which is awesome and that gets stored in a favicon directory and rendered with a link tag to its location. So maybe putting it in its own docs/favicons subdirectory and then specifying the location in a link tag would work, but if there isn't currently an in_header option in xaringan I'm not sure this would work yet.
Hi @aedobbyn -- sorry for the run-around, but I do think my suggestion(s) will work! When you use includes the HTML ends up in the <head> section, so you don't need the <head> tags in header.html.
I forked your slides and tested it out and the favicon is working! The important (and very small) change is in this diff.
For reference, moon_reader() is basically a wrapper/pre-processor for rmarkdown::html_document(), so most additional options to html_document() that aren't covered by moon_reader() are still valid.
Omg wow nice! Thank you for solving this! Was that js added automatically or did you have to put it in by hand yourself? (I did)
> devtools::session_info()
β Session info ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
setting value
version R version 3.5.2 (2018-12-20)
os macOS Mojave 10.14
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2019-02-03
β Packages ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
package * version date lib source
assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.5.0)
backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.0)
bench 1.0.1 2018-06-06 [1] CRAN (R 3.5.0)
callr 3.1.1 2018-12-21 [1] CRAN (R 3.5.0)
cli 1.0.1 2018-09-25 [1] CRAN (R 3.5.0)
clipr 0.5.0 2019-01-11 [1] CRAN (R 3.5.2)
colorspace 1.4-0 2019-01-13 [1] CRAN (R 3.5.2)
crayon 1.3.4 2018-12-20 [1] Github (r-lib/crayon@74bee76)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.0)
devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.1)
digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.0)
emo 0.0.0.9000 2018-07-05 [1] Github (hadley/emo@02a5206)
evaluate 0.11 2018-07-17 [1] CRAN (R 3.5.0)
fs 1.2.6 2018-08-23 [1] CRAN (R 3.5.0)
glue 1.3.0 2018-07-17 [1] CRAN (R 3.5.0)
hms 0.4.2 2018-03-10 [1] CRAN (R 3.5.0)
htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.0)
httpuv 1.4.5.1 2018-12-18 [1] CRAN (R 3.5.0)
httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.0)
kableExtra * 1.0.1 2019-01-22 [1] CRAN (R 3.5.2)
knitr * 1.21 2018-12-10 [1] CRAN (R 3.5.1)
later 0.7.3 2018-06-08 [1] CRAN (R 3.5.0)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.5.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0)
mime 0.6 2018-10-05 [1] CRAN (R 3.5.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.0)
packrat 0.4.9-10 2018-08-10 [1] Github (rstudio/packrat@7d320b1)
pillar 1.3.1.9000 2019-02-03 [1] Github (r-lib/pillar@3a54b8d)
pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.0)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.0)
processx 3.2.1 2018-12-05 [1] CRAN (R 3.5.0)
promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.0)
purrr 0.3.0 2019-01-27 [1] CRAN (R 3.5.1)
R6 2.3.0 2018-10-04 [1] CRAN (R 3.5.0)
Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.5.0)
readr 1.3.1 2018-12-21 [1] CRAN (R 3.5.0)
remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.0)
reprex 0.2.1 2018-09-16 [1] CRAN (R 3.5.0)
rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.2)
rmarkdown 1.11 2018-12-08 [1] CRAN (R 3.5.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0)
rstudioapi 0.9.0 2019-01-09 [1] CRAN (R 3.5.2)
rvest 0.3.2 2016-06-17 [1] CRAN (R 3.5.0)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.0)
servr 0.11 2018-10-23 [1] CRAN (R 3.5.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.0)
stringi 1.2.4 2018-07-20 [1] CRAN (R 3.5.0)
stringr 1.3.1 2018-05-10 [1] CRAN (R 3.5.0)
testthat 2.0.1 2018-10-13 [1] CRAN (R 3.5.0)
tibble 2.0.1 2019-01-12 [1] CRAN (R 3.5.2)
usethis 1.4.0 2018-08-14 [1] CRAN (R 3.5.0)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.0)
webshot 0.5.1 2018-09-28 [1] CRAN (R 3.5.0)
whisker 0.3-2 2013-04-28 [1] CRAN (R 3.5.0)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0)
xaringan * 0.8 2018-10-23 [1] CRAN (R 3.5.0)
xfun 0.4 2018-10-23 [1] CRAN (R 3.5.0)
xml2 1.2.0 2018-01-24 [1] CRAN (R 3.5.0)
yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.0)
Awesome, glad that worked for you too! Yeah, I noticed that js but Iβm not sure where it came from. I donβt think itβs strictly necessary. I did install xaringan from github right before rendering... π€·ββοΈ
Oh yeah you're right, it's not necessary, probably just a result of your installing a different version of the package. Now that I look at it it should just make external links open in a new tab (I think? though mine actually don't so π€·ββοΈ) Anyway, thanks again, cheers!
I have a very similar problem with the favicon displayed offline but not online.
repo: https://github.com/chrisdane/chrisdane.github.io; page: https://chrisdane.github.io/
I have the line
favicon: "figs/favicon.ico"
in the index.Rmd but it does not work online.
Thanks a lot for any help!
Chris
Hi @chrisdane,
This issue is with xaringan and yours shows bookdown related. It would be better to have things organized in the right place. It is always better to follow issue guide and post in the right place, in a new topic if yours is not directly related. Also for questions, please use Stackoverflow and RStudio Community that are better suited.
That being said, where did you found that adding this YAML field would work ? I don't think that this field is supported.
Here is a recipe on how to add favicon for a html document: https://bookdown.org/yihui/rmarkdown-cookbook/favicon.html
You can adapt for bookdown I think.
If you need further help, please open a thread in https://community.rstudio.com is the correct category so that we keep things organized and not mix discussion in one old issue here.
Thank you.
Most helpful comment
Two suggestions: First, from browsing your repo, it seems like the favicon didn't make it into
docs. I'd say there's a good chance this is the problem, as I don't think GitHub pages "sees" anything outside the folder/branch from which the pages are served.But if that doesn't work, then maybe the link tag isn't making it into
<head>and this could be the problem?In which case, I'm pretty sure that you can use
includesas an option ofmoon_readerin the YAML header to pass an HTML file asin_header, ala html_document(), as in something like this:Btw, I've really been wanting to learn drake and your slides are π₯π₯π₯ and thanks for opening this issue so I could discover them! π