I've published a book/manual with bookdown and hosted it on Github-pages.
My browser has the Zotero-connector which scans for bibliographic metadata and allows to directly ingest the bibliographic reference into my Zotero database.
However, when I visit my bookdwon-website it is currently recognized as a book and the authors (as listed in the yaml) are mixed up when using the Zotero connector. On this site it is explained how to integrate ContextObjects in Spans (COinS) in the index.html of a website. So when I create a correct bibliographic reference in Zotero, export it as COinS and paste the generated COinS-html into the index.html, the Zotero-connector detects this meta-data and ingests it correctly into Zotero.
Is it possible to embed bibliographic metadata (COinS) directly in the Rmarkdown files when building the book in Bookdown, so there would be no need to copy/paste this after every build and update?
That would, for instance, require to include the following html in the html-output generated by Bookdown:
This line of html with the bibliographic meta data should be inserted anywhere in the body of the index.html.
When I copy this line of html directly in index.Rmd (<span class= ...), for instance right under the YAML and before the first heading, is doesn't become part of index.html when I build the book. with bookdown
If you want it to show up using this method you have to set an option in index.Rmd in the YAML at the top:
always_allow_html: yes
There's an even better solution, though, I suspect. You want this to appear on every page of the book that somebody browses to, probably. Which means the best way to accomplish this is by placing it in a separate HTML file and then including that in your book on every page. You do that by saving a file (let's call it COinS.html) into your project with just that span code inside it. Then you include it like so in the bookdown::gitbook section of your YAML, either in index.Rmd or _output.yml:
I am not sure this is required. This need to be set mainly for htmlwidget or other HTML only content, that would need to appear in a non-HTML format.
Using before_body is indeed the solution to have this inserted on each page.
Anything before One level headings won't be included in a gitbook output because of the splitting that happens in gitbook format. You need to put it after the first header or use the before_body insertion
Pretty sure it is. The first thing I did was try inserting her span code into the demo book, and it didn't show up in the page source until I added the always_allow_html option.
Edit: After reading about that option, perhaps this is just a bug?
I did the same thing and this option does seem to change anything on my end. If I put the span before the first level header in the index.Rmd file, I don't get the span in the output, no matter that option.
Anyway, it is indeed not made for this use as you saw in the documentation
My apologies. I cannot reproduce my claim above. I know I didn't have it before the header, so I must have simply fumbled my initial search in the source code.
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: