视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
build-pkgdown-site【文档与办公】Build and deploy a pkgdown documentation site for an R package to GitHub Pages. Covers _pkgdown.yml configuration, theming, article organization, reference index customization, and deployment methods. Use when creating a documentation site for a new or existing package, customizing layout or navigation, fixing 404 errors on a deployed site, or migrat…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Configure and deploy pkgdown documentation website for R package.
usethis::use_pkgdown()
Creates _pkgdown.yml, adds pkgdown to .Rbuildignore.
Got: _pkgdown.yml exists in project root. .Rbuildignore contains pkgdown-related entries.
If fail: Install pkgdown with install.packages("pkgdown"). _pkgdown.yml already exists? Function updates .Rbuildignore without overwriting config.
_pkgdown.ymlurl: https://username.github.io/packagename/
development:
mode: release
template:
bootstrap: 5
bootswatch: flatly
navbar:
structure:
left: [intro, reference, articles, news]
right: [search, github]
components:
github:
icon: fa-github
href: https://github.com/username/packagename
reference:
- title: Core Functions
desc: Primary package functionality
contents:
- main_function
- helper_function
- title: Utilities
desc: Helper and utility functions
contents:
- starts_with("util_")
articles:
- title: Getting Started
contents:
- getting-started
- title: Advanced Usage
contents:
- advanced-features
- customization
Critical: Set development: mode: release. Default mode: auto causes 404 errors on GitHub Pages — appends /dev/ to URLs.
Got: _pkgdown.yml contains valid YAML with url, template, navbar, reference, articles sections appropriate for package.
If fail: Validate YAML syntax with online YAML linter. Ensure all function names in reference.contents match actual exported functions.
pkgdown::build_site()
Got: docs/ directory created with complete site including index.html, function reference pages, articles.
If fail: Common issues: missing pandoc (set RSTUDIO_PANDOC in .Renviron), missing vignette dependencies (install suggested packages), broken examples (fix or wrap in \dontrun{}).
pkgdown::preview_site()
Verify navigation, function reference, articles, search work correctly.
Got: Site opens in browser at localhost. All navigation links work, function reference pages render, search returns results.
If fail: Preview doesn't open? Manually open docs/index.html in browser. Pages missing? Check devtools::document() was run before building site.
Method A: GitHub Actions (Recommended)
See setup-github-actions-ci skill for pkgdown workflow.
Method B: Manual Branch Deployment
# Build site
Rscript -e "pkgdown::build_site()"
# Create gh-pages branch if it doesn't exist
git checkout --orphan gh-pages
git rm -rf .
cp -r docs/* .
git add .
git commit -m "Deploy pkgdown site"
git push origin gh-pages
# Switch back to main
git checkout main
Got: gh-pages branch exists on remote with site files at root level.
If fail: Push rejected? Ensure you have write access to repository. Using GitHub Actions deployment instead? Skip this step, follow setup-github-actions-ci skill.
gh-pages branch, / (root) folderGot: Site available at https://username.github.io/packagename/ within a few minutes.
If fail: Site returns 404? Verify Pages source matches deployment method (branch deployment requires "Deploy from a branch"). Check development: mode: release set in _pkgdown.yml.
URL: https://username.github.io/packagename/, https://github.com/username/packagename
Got: DESCRIPTION URL field contains both pkgdown site URL and GitHub repository URL, separated by comma.
If fail: R CMD check warns about invalid URLs? Verify pkgdown site actually deployed and accessible before adding URL.
development: mode: release set in _pkgdown.ymldevelopment: mode: auto (default). Change to mode: release.devtools::document() first.vignette("name") syntax in cross-references, not file paths.man/figures/logo.png, reference in _pkgdown.yml.url field in _pkgdown.yml set correctly.Rscript may resolve to cross-platform wrapper instead of native R. Check with which Rscript && Rscript --version. Prefer native R binary (e.g., /usr/local/bin/Rscript on Linux/WSL) for reliability. See Setting Up Your Environment for R path configuration.setup-github-actions-ci - automated pkgdown deployment workflowwrite-roxygen-docs - function documentation appearing on sitewrite-vignette - articles appearing in site navigationrelease-package-version - trigger site rebuild on release