视觉画布设计
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 快照 · 自动分类 · 以原作者文档为准
Config + deploy pkgdown doc site for R pkg.
usethis::use_pkgdown()
Creates _pkgdown.yml + adds pkgdown to .Rbuildignore.
→ _pkgdown.yml in project root. .Rbuildignore has pkgdown entries.
If err: Install pkgdown via install.packages("pkgdown"). _pkgdown.yml already exists → fn updates .Rbuildignore w/o 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 404s on GitHub Pages (appends /dev/ to URLs).
→ _pkgdown.yml valid YAML w/ url, template, navbar, reference, articles appropriate for pkg.
If err: Validate YAML syntax w/ online linter. All fn names in reference.contents match actual exported fns.
pkgdown::build_site()
→ docs/ dir created w/ complete site incl index.html, fn ref pages, articles.
If err: Common issues: missing pandoc (set RSTUDIO_PANDOC in .Renviron), missing vignette deps (install suggested pkgs), broken examples (fix or wrap in \dontrun{}).
pkgdown::preview_site()
Verify nav, fn ref, articles, search work.
→ Site opens in browser at localhost. Nav links work, ref pages render, search returns results.
If err: Preview doesn't open → manually open docs/index.html. Pages missing → check devtools::document() ran before build.
Method A: GitHub Actions (Recommended)
See setup-github-actions-ci skill for pkgdown workflow.
Method B: Manual Branch Deploy
# 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
→ gh-pages branch on remote w/ site files at root.
If err: Push rejected → ensure write access. Using GitHub Actions instead → skip + follow setup-github-actions-ci.
gh-pages branch, / (root) folder→ Site available at https://username.github.io/packagename/ within min.
If err: 404 → verify Pages source matches deploy method (branch deploy needs "Deploy from a branch"). Check development: mode: release in _pkgdown.yml.
URL: https://username.github.io/packagename/, https://github.com/username/packagename
→ DESCRIPTION URL has pkgdown site URL + GitHub repo URL, comma-separated.
If err: R CMD check warns invalid URLs → verify pkgdown site actually deployed + accessible before adding.
development: mode: release setdevelopment: mode: auto (default). → mode: releasedevtools::document() firstvignette("name") syntax for cross-refs, not file pathsman/figures/logo.png, ref in _pkgdown.ymlurl field in _pkgdown.yml set correctlyRscript may resolve to cross-platform wrapper vs native. Check which Rscript && Rscript --version. Prefer native (e.g., /usr/local/bin/Rscript on Linux/WSL). See Setting Up Your Environmentsetup-github-actions-ci — automated pkgdown deploy workflowwrite-roxygen-docs — fn docs that appear on sitewrite-vignette — articles in site navrelease-package-version — trigger rebuild on release