pkgdown in-header.html for vignette

I'm updating an old pkgdown website, and I'm having some trouble with html that should be injected in the <head> of articles (from vignettes). For the standalone vignette I have

---
title: "Dimer"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  rmarkdown::html_vignette:
    includes:
      in_header: "../../inst/_x3d_header.html"
---

where the in_header field points to html lines that load some javascript library (x3dom) needed later on the page. This works fine for the vignette, however when I run pkgdown on the package, the header content isn't present. With a previous version of pkgdown I found that

pkgdown:
  as_is: true
output:
  rmarkdown::html_vignette:
    includes:
      in_header: "../../inst/_x3d_header.html"

sorted things out (albeit with some minor css formatting quirks). Updating pkgdown to the dev version (which seemed warranted to remove a deprecated markdown_github warning), however, I no longer see the header stuff being used. There's some mention of in-header.html which sounds like what I need, but I have no idea where to place it and tell pkgdown about it in the build_site() process.

pkgdown can now use the templates “in-header.html”/“after-head.html”, “before-body.html” and “after-body.html” whose content will be placed (similarly to bookdown options in_header , before_body and after_body ), respectively, at the end of the <head> tag; right below the opening <body> tag; and before the closing tag </body> (#1487).

Never mind, I eventually found some instructions

Placing a file in-header.html under pkgdown/templates/ in the repo does the right thing.

2 Likes

Good to read you found a solution!

Regarding as_is see also the recent changes (in the dev version) including docs clarifications https://github.com/r-lib/pkgdown/pull/1793

This topic was automatically closed 7 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.