I'd like to make a template package for my pkgdown site. I'm trying to figure out how it works from the tidytemplate repo. From what I understand, I need a base bootstrap template located in /scss and add my custom style in inst/pkgdown/assets. I guess I'm missing a few files to make it work. The tidytemplate repo has a /scss/bootstrap directory and /scss/_bootstrap.scss file.
Where do these come from? When downloading a base bootswatch template, I can only download _bootswatch.scss and _variables.scss. Same on the bootstrap website, I can't seem to find anything similar to _bootstrap.scss/bootstrap files.
If you're customising one site only, you don't need a template package, you can tweak the pkgdown configuration of your package directly. A template package is useful when you want to share those customisations across several packages.
I probably misunderstood the initial purpose of extra.css and thought it'd add new rules to be used with bslib. In the end, pkgdown/extra.css worked fine. Thanks!
What's the purpose of having css files in inst/pkgdown/assets (like in tidytemplate) though?
Edit:
I did a bit more testing. pkgdown/extra.css works but not inst/pkgdown/extra.css despite adding the following in _pkgdown.yml:
Sorry, I meant the purpose of having the css in assets instead of using extra.css
One can read in the pkgdown documentation ("Template packages" section):
inst/pkgdown/extra.scss will be added to the bslib ruleset.
Assets in inst/pkgdown/assets/ will be copied in to the destination directory.
I initially understood the former as "will add rules to be used with the bslib option in _pkgdown.yaml" when it's actually overriding the default css rules. The latter simply doesn't make any sense to me.
I did more testing but I'm still unable to make it work.
Here's a test repo with the custom theme: GitHub - arnaudgallou/cygne
I tried it with the inst/pkgdown/extra.css and inst/pkgdown/assets/foo.css. The css simply doesn't have any effect on the output.
That one is copied to the pkgdown website, however it's not linked from the website head, only extra.css/extra.scss would be. So if you wanted to use inst/pkgdown/assets/cygne.css you would also need a template configuration file in inst/pkgdown/_pkgdown.yml that has
It works if it is renamed to inst/pkgdown/extra.scss or if it stored in pkgdown/extra.cssso that might be a pkgdown docs problem / bug. I opened an issue.
Awesome! The template package works now. I've tried to use it on the other package but got a dependency error when running GitHub actions (saying it can't find the template package):
Thanks for the explanation. The pkgdown documentation would definitely benefit from this IMO.
Maybe one last question related to the topic.
I edited css rules from the default theme used by pkgdown. Although unlikely, assuming the default theme changes and uses rules that my custom theme doesn't override, the design of the current site should also change. Is there a way to store the base design within the template package to avoid that?
I edited css rules from the default theme used by pkgdown. Although unlikely, assuming the default theme changes and uses rules that my custom theme doesn't override, the design of the current site should also change. Is there a way to store the base design within the template package to avoid that?
All pkgdown changes are for the better. More seriously, you could
use a fixed pkgdown version (using renv) see for instance this action
follow pkgdown development by subscribing to the releases, and reading the changelog (most important changes should be in there). See Configuring notifications - GitHub Docs