Cover-page does not show up

bookdown

#1

Hi,

I am learning to use bookdown. So far I was able to compile my Rmd documents in sequence and the gitbook is compiled. However, i was not able to get a cover-page for my gitbook.

I did the exact code to put a png in images folder under the root directory for the book.

Could someone guide me how to get a book cover compiled.

thank you
Ram


#2

Hi @Ram,

It's really difficult to say what's going on without some code. Could you please include a snippet with how you've got the path to the image setup. Also, assuming you are hosting this on GitHub, the link might help as well.

Thanks!


#3

Hi @mara

Thank you for your reply. As it did not work for me on a local computer, I did not push it to git hub and now I am on a different machine. But I attach a screenshot of my root folder (last version). In the images folder, I had put a .png file. And then in yaml metadata of my index.Rmd, I said : cover-image: "images/cover.png" with the same indent level as title and author etc. Are there any size specifications for the image?

I am always confused where the metadata should be, in _output.yml or bookdown.yml or index.Rmd :neutral_face:

Thank you again
Ram


#4

It sounds like the cover-image YAML option is for media previews of the site.

A nice effect of setting description and cover-image is that when you share the link of your book on some social network websites such as Twitter, the link can be automatically expanded to a card with the cover image and description of the book. https://bookdown.org/yihui/bookdown/html.html#gitbook-style

The bookdown book manually inserts the cover into index.Rmd with

```{r fig.align='center', echo=FALSE, include=identical(knitr:::pandoc_to(), 'html'), fig.link='https://www.crcpress.com/product/isbn/9781138700109'}
knitr::include_graphics('images/cover.jpg', dpi = NA)
```

(The include chunk option says to include the output of this chunk when the output format is HTML.)


#5

hi @tjmahr

Thank you for the reply. I probably do not understand you clearly. I followed your suggestion and added the r code in the beginning of my document in index.Rmd like so...


```{r fig.align='center', echo=FALSE, include=identical(knitr:::pandoc_to(), 'html'), }
knitr::include_graphics('cover.png', dpi = NA)

my cover.png is in the root directory of the book project, so I just write the filename (cover.png), but it does not show up in my gitbook.

Could you clarify a bit more on your response.

Thank you
Ram


#6

It looks like the cover art is inserted manually in the bookdown example. knitr::include_graphics() is one way to insert images. You can also try to just insert the image manually with an image tag in markdown.

![book cover](cover.png)