关于
This skill helps developers build and deploy a pkgdown documentation site for an R package to GitHub Pages. It covers configuration, theming, article organization, and deployment methods like branch-based or GitHub Actions. Use it when creating or customizing a package's documentation site or fixing deployment issues.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/build-pkgdown-site在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Build pkgdown Site
Configure and deploy pkgdown documentation website for R package.
When Use
- Creating documentation site for R package
- Customizing pkgdown layout, theme, navigation
- Fixing 404 errors on deployed pkgdown site
- Migrating between deployment methods
Inputs
- Required: R package with roxygen2 documentation
- Required: GitHub repository
- Optional: Custom theme or branding
- Optional: Vignettes to include as articles
Steps
Step 1: Initialize pkgdown
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.
Step 2: Configure _pkgdown.yml
url: 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.
Step 3: Build Locally
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{}).
Step 4: Preview Site
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.
Step 5: Deploy to GitHub Pages
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.
Step 6: Configure GitHub Pages
- Go to repository Settings > Pages
- Set Source to "Deploy from a branch"
- Select
gh-pagesbranch,/ (root)folder - Save
Got: 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.
Step 7: Add URL to DESCRIPTION
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.
Checks
- Site builds locally without errors
- All function reference pages render correctly
- Articles/vignettes accessible and render properly
- Search functionality works
- Navigation links correct
- Site deploys successfully to GitHub Pages
- No 404 errors on deployed site
-
development: mode: releaseset in_pkgdown.yml
Pitfalls
- 404 errors after deployment: Almost always caused by
development: mode: auto(default). Change tomode: release. - Missing reference pages: Functions must be exported and documented. Run
devtools::document()first. - Broken vignette links: Use
vignette("name")syntax in cross-references, not file paths. - Logo not showing: Place logo at
man/figures/logo.png, reference in_pkgdown.yml. - Search not working: Requires
urlfield in_pkgdown.ymlset correctly. - Wrong R binary on hybrid systems: On WSL or Docker,
Rscriptmay resolve to cross-platform wrapper instead of native R. Check withwhich Rscript && Rscript --version. Prefer native R binary (e.g.,/usr/local/bin/Rscripton Linux/WSL) for reliability. See Setting Up Your Environment for R path configuration.
See Also
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
GitHub 仓库
Frequently asked questions
What is the build-pkgdown-site skill?
build-pkgdown-site is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform build-pkgdown-site-related tasks without extra prompting.
How do I install build-pkgdown-site?
Use the install commands on this page: add build-pkgdown-site to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does build-pkgdown-site belong to?
build-pkgdown-site is in the Meta category, tagged word and design.
Is build-pkgdown-site free to use?
Yes. build-pkgdown-site is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.
相关推荐技能
Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
