I see that we can customize the look of bookdown HTML with
---
output:
bookdown::html_book:
includes:
in_header: style.css
---
and there is also before_body
and after_body
, as described here: https://bookdown.org/yihui/bookdown/yaml-options.html
But I'm not sure how I can insert some text or a div that displays directly above every chapter heading in my HTML output. For example, I want an alert box that says "Warning: Early Draft" with an alert symbol and a link to another page.
Similarly, how can I insert a div directly below the bottom of the text of each section (i.e. html page)?
Can I use includes:
or do I need to modify some kind of template? I see mention of templates in the bookdown pkg (https://bookdown.org/yihui/bookdown/html.html#bootstrap-style), but if this is what I need to edit, then I want to have one that lives with my bookdown Rmd files
To follow up, I discussed this with the package author, who confirmed that the template was hard-coded. He kindly advised me on how this might be changed , so I submitted a pull request to the bookdown package. And now we can use _output.yml
to inject text and HTML just above each chapter/section title like this:
bookdown::gitbook:
includes:
before_body: xxxx.html
Where xxx.html
is a HTML file containing the content to be inserted above the title.