メインコンテンツまでスキップ

GitHub Pages に載せる

このサイトは静的ビルド前提です。サンドボックスからデプロイはしません。ローカルまたは CI で build/ を生成し、Pages に公開してください。

設定

docusaurus.config.js:

項目プロジェクト Pages 例カスタムドメイン / user site
urlhttps://<user>.github.iohttps://docs.example.com
baseUrl/mercari_search//
organizationNameGitHub user/org同上
projectNameリポジトリ名同上

ビルド時に上書き:

export DOCUSAURUS_URL=https://yourname.github.io
export DOCUSAURUS_BASE_URL=/mercari_search/
export DOCUSAURUS_ORG=yourname
export DOCUSAURUS_PROJECT=mercari_search
cd website
npm ci
npm run build

成果物は website/build/ です。

デプロイ例

  • GitHub Actions peaceiris/actions-gh-pagesactions/upload-pages-artifactwebsite/build を公開
  • または npm run deployGIT_USER 等の Docusaurus 標準フロー)
cd website
npm run build
# build/ を gh-pages ブランチまたは Pages artifact へ
注記

既定の baseUrl/(ルート公開) です。Cloudflare Pages やカスタムドメイン直下向け。

GitHub Project Pages(https://user.github.io/repo/)では必ず:

export DOCUSAURUS_URL=https://YOURUSER.github.io
export DOCUSAURUS_BASE_URL=/YOUR_REPO/
npm run build:gh-pages

BASE_URL が配信パスと違うと「Current configured baseUrl = … We suggest trying baseUrl = /」バナーが出ます。

Cloudflare 向けは Cloudflare Pagesnpm run build:pagesdeploy:pages)。