bookdown header

I'm creating an RMarkdown site using {bookdown}.

I've created a header.html file that I want to be inserted in the <head>...</head> section of each of my chapters, not just the first chapter. My YAML has the following:

      in_header: "header.html"
      css: style.css  
        collapse: section

but the header.html file is only appearing on the index.html page not any of my other Chapters. What is the correct syntax for this?

You probably need to put it in your bookdown.yml file, if you have one.

Did you define that in _output.yml file ? If so, it should apply to all Rmd file, so all chapter. In a small test I have just done with bookdown-demo, it works correctly and this is applied in all headers.

Oops. Yeah. I got the name wrong. Was going off memory. I’m assuming he made the same mistake I did and put it in with the other yml code in index.rmd that is there in the bookdown demo. I only figured out it had to go in _output via trial and error when it didn’t work to put it in index.

I haven’t figured out the difference between what should go in each place. Can I just get rid of the yml in index and put all the config in _output.yml? Why is it split into two places?

1 Like

hum... good question. A design choice for now. _output.yml can serve to define formats and its options for all the Rmd rendered in a project. You can replace any output: from your Rmd header by this file. However, the YAML header of an Rmd also contains other information for pandoc to work with, (like title:, date:, ...), and I don't think you could put that in the _output.yml - they are more document related than project related.

Anyway, you could be interested to add a :+1: there:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.