Use pkgdown.offline

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

pkgdown.offline supports offline builds of pkgdown websites. It implements identically named functions to mask the original site initialization and site building functions for convenient drop-in replacements in your environment-constrained development or CI/CD workflows that cannot access the internet.

Try it out locally

To test the offline build workflow, first clear the pkgdown external frontend dependencies cache that might exist in your environment:

pkgdown.offline::clear_cache()

Create a new package. For example:

usethis::create_package(file.path(tempdir(), "pkg"))

Switch off internet connection. In the new project, run:

usethis::use_pkgdown()
pkgdown.offline::build_site()

Use in production environments

In practice, you can replace pkgdown::build_site() calls with pkgdown.offline::build_site() in your wrapper function or CI/CD workflow to achieve offline builds. Similarly, you can use pkgdown.offline::init_site() if a pkgdown::init_site() step was involved in your workflow.



Try the pkgdown.offline package in your browser

Any scripts or data that you put into this service are public.

pkgdown.offline documentation built on June 8, 2025, 1:59 p.m.