pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Include arbitrary files

Open josherrickson opened this issue 2 years ago • 4 comments

Am I missing an automatic way to flag specific files which should be included in the built site? I'm trying to use the pkgdown site as a drat repository, and since pkgdown cleans the gh-pages branch on every rebuild, I'm having to manually add the files back.

Specifically, I need to place some files in bin/ and src/contrib/. I have these on my main branch, and ideally I'd like some way to tell pkgdown to just copy those locations/files directly over to gh-pages.

josherrickson avatar Mar 26 '22 10:03 josherrickson

Not sure if this will help, but I have a repo + pkgdown website where I host arbitrary files:

https://github.com/vincentarelbundock/Rdatasets/

What I do is basically:

  • commit the files to the gh-pages branch
  • deploy with pkgdown::deploy_to_branch(clean = FALSE)

Note the important clean argument.

The specific steps I take are listed in a reminder at the bottom of my README, but they are repo-specific.

vincentarelbundock avatar Apr 06 '22 16:04 vincentarelbundock

Thanks - I do something similar right now but its helpful to see another example!

Where this falls down for me is needing to do clean = FALSE. This could lead to a lot of cruft building up in gh-pages. I'm OK with pkgdown cleaning out the existing gh-pages, I just want to be able to flag files that pkgdown copies over automatically, after cleaning out the existing.

josherrickson avatar Apr 06 '22 16:04 josherrickson

Indeed, we have a similar problem. We want to make available in the website a vignette that can only be built in PDF and we have to run a quite complicated sequence of commands:

https://github.com/MLopez-Ibanez/irace/blob/f8c50f9cc18c4a4c1d96b7e0bf1b95d0417ec5a4/.github/workflows/R-CMD-check.yaml#L193-L218

MLopez-Ibanez avatar May 02 '22 14:05 MLopez-Ibanez

Seems like it would be reasonable to include some config that let you declare paths as "known" and not to be cleaned up.

hadley avatar May 31 '22 21:05 hadley

Alternatively we could have a convention like where all files in pkgdown/include are copied to the root directory of the package site.

hadley avatar Apr 17 '24 22:04 hadley

Actually, template packages use inst/pkgdown/assets/, so would probably make the most sense to copy pkgdown/assets to the docs destination dir.

hadley avatar Apr 25 '24 16:04 hadley

Oh, and indeed the code to do that already exists 😬

hadley avatar Apr 25 '24 16:04 hadley

And it's already documented in https://pkgdown.r-lib.org/articles/customise.html#additional-html-and-files, so I'm going to close this issue 😄

hadley avatar Apr 25 '24 16:04 hadley