build-pkgdown-site
About
This skill builds and deploys pkgdown documentation sites for R packages to GitHub Pages. It helps developers configure site layout, themes, navigation, and articles via `_pkgdown.yml`. Use it when creating new documentation sites, customizing existing ones, fixing deployment errors, or migrating deployment methods.
Quick Install
Claude Code
Recommendednpx 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-siteCopy and paste this command in Claude Code to install this skill
Documentation
pkgdownサイトのビルド
Rパッケージのpkgdownドキュメントウェブサイトを設定してデプロイする。
使用タイミング
- RパッケージのドキュメントサイトをGitHub Pagesに作成する時
- pkgdownのレイアウト、テーマ、またはナビゲーションをカスタマイズする時
- デプロイ済みpkgdownサイトの404エラーを修正する時
- デプロイ方法を移行する時
入力
- 必須: roxygen2ドキュメントを持つRパッケージ
- 必須: GitHubリポジトリ
- 任意: カスタムテーマまたはブランディング
- 任意: 記事として含めるビネット
手順
ステップ1: pkgdownの初期化
usethis::use_pkgdown()
これにより_pkgdown.ymlが作成され、pkgdownが.Rbuildignoreに追加される。
期待結果: _pkgdown.ymlがプロジェクトルートに存在する。.Rbuildignoreにpkgdown関連のエントリが含まれる。
失敗時: install.packages("pkgdown")でpkgdownをインストールする。_pkgdown.ymlが既に存在する場合、関数は設定を上書きせずに.Rbuildignoreを更新する。
ステップ2: _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
重要: development: mode: releaseを設定すること。デフォルトのmode: autoはGitHub PagesでURLに/dev/が付加されて404エラーを引き起こす。
期待結果: _pkgdown.ymlがパッケージに適したurl、template、navbar、reference、articlesセクションを含む有効なYAMLを持つ。
失敗時: オンラインYAMLリンターでYAML構文を検証する。reference.contentsのすべての関数名が実際にエクスポートされた関数と一致しているか確認する。
ステップ3: ローカルでのビルド
pkgdown::build_site()
期待結果: docs/ディレクトリがindex.html、関数リファレンスページ、記事を含む完全なサイトで作成される。
失敗時: 一般的な問題:pandocの欠如(.RenvironでRSTUDIO_PANDOCを設定)、ビネット依存関係の欠如(推奨パッケージをインストール)、または壊れた例(修正するか\dontrun{}で囲む)。
ステップ4: サイトのプレビュー
pkgdown::preview_site()
ナビゲーション、関数リファレンス、記事、検索が正しく機能しているか確認する。
期待結果: サイトがlocalhostのブラウザで開く。すべてのナビゲーションリンクが機能し、関数リファレンスページがレンダリングされ、検索が結果を返す。
失敗時: プレビューが開かない場合、ブラウザでdocs/index.htmlを手動で開く。ページが欠如している場合、サイトをビルドする前にdevtools::document()が実行されたか確認する。
ステップ5: GitHub Pagesへのデプロイ
方法A: GitHub Actions(推奨)
pkgdownワークフローについてはsetup-github-actions-ciスキルを参照する。
方法B: 手動ブランチデプロイ
# サイトをビルド
Rscript -e "pkgdown::build_site()"
# gh-pagesブランチが存在しない場合は作成
git checkout --orphan gh-pages
git rm -rf .
cp -r docs/* .
git add .
git commit -m "Deploy pkgdown site"
git push origin gh-pages
# mainに戻る
git checkout main
期待結果: gh-pagesブランチがリモートにルートレベルのサイトファイルとともに存在する。
失敗時: プッシュが拒否される場合、リポジトリへの書き込みアクセスがあることを確認する。GitHub Actionsデプロイを使用する場合は、このステップをスキップしてsetup-github-actions-ciスキルに従う。
ステップ6: GitHub Pagesの設定
- リポジトリの設定 > Pagesに移動する
- ソースを「Deploy from a branch」に設定する
gh-pagesブランチ、/ (root)フォルダを選択する- 保存する
期待結果: 数分以内にhttps://username.github.io/packagename/でサイトが利用可能になる。
失敗時: サイトが404を返す場合、PagesのソースがデプロイメソッドにマッチしていることRを確認する(ブランチデプロイには「Deploy from a branch」が必要)。_pkgdown.ymlにdevelopment: mode: releaseが設定されているか確認する。
ステップ7: DESCRIPTIONへのURLの追加
URL: https://username.github.io/packagename/, https://github.com/username/packagename
期待結果: DESCRIPTIONのURLフィールドにpkgdownサイトURLとGitHubリポジトリURLの両方がカンマで区切られて含まれる。
失敗時: R CMD checkが無効なURLを警告する場合、URLを追加する前にpkgdownサイトが実際にデプロイされてアクセス可能であることを確認する。
バリデーション
- サイトがエラーなくローカルでビルドされる
- すべての関数リファレンスページが正しくレンダリングされる
- 記事/ビネットがアクセス可能で正しくレンダリングされる
- 検索機能が動作する
- ナビゲーションリンクが正しい
- サイトがGitHub Pagesに正常にデプロイされる
- デプロイ済みサイトに404エラーがない
-
_pkgdown.ymlにdevelopment: mode: releaseが設定されている
よくある落とし穴
-
デプロイ後の404エラー: ほぼ常に
development: mode: auto(デフォルト)が原因。mode: releaseに変更する -
リファレンスページの欠如: 関数はエクスポートされてドキュメント化されていなければならない。最初に
devtools::document()を実行する -
壊れたビネットリンク: 相互参照にはファイルパスではなく
vignette("name")構文を使用する -
ロゴが表示されない: ロゴを
man/figures/logo.pngに配置して_pkgdown.ymlで参照する -
検索が機能しない:
_pkgdown.ymlのurlフィールドが正しく設定されていることが必要 -
ハイブリッドシステムでの誤った R バイナリ:WSL や Docker では、
Rscriptがネイティブ R の代わりにクロスプラットフォームラッパーに解決される場合があります。which Rscript && Rscript --versionで確認してください。信頼性のために、ネイティブ R バイナリ(例:Linux/WSL では/usr/local/bin/Rscript)を優先してください。R パス設定については Setting Up Your Environment を参照してください。
関連スキル
setup-github-actions-ci- 自動pkgdownデプロイワークフローwrite-roxygen-docs- サイトに表示される関数ドキュメントwrite-vignette- サイトナビゲーションに表示される記事release-package-version- リリース時にサイトの再ビルドをトリガーする
GitHub Repository
Related Skills
content-collections
MetaThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
polymarket
MetaThis skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.
creating-opencode-plugins
MetaThis skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.
sglang
MetaSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
